所以,我有3個用戶控件:SharedSizeGroup到在不同的父控制不同網格
1. SectionV.xaml
<UserControl x:Class="NumberedMusicalScoresWriter.V.SectionV"...>
...
<Grid Background="{Binding BackgroundColor, Mode=OneWay}" Grid.IsSharedSizeScope="True">
...
<V:BarV Grid.Column="0" Grid.Row="0" DataContext="{Binding GClefBarVM, Mode=OneWay}"/>
<V:BarV Grid.Column="0" Grid.Row="2" DataContext="{Binding FClefBarVM, Mode=OneWay}"/>
</Grid>
...
2. BarV.xaml
<UserControl x:Class="NumberedMusicalScoresWriter.V.BarV"...>
...
<Grid Background="{Binding BackgroundColor, Mode=OneWay}">
...
<ItemsControl Grid.Column="0" Grid.Row="0"
ItemsSource="{Binding NotationGroupVMs, Mode=OneWay}">
...
<ItemsControl.ItemTemplate>
<DataTemplate>
<V:NotationGroupV/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
...
3 NotationGroupV.xaml
<UserControl x:Class="NumberedMusicalScoresWriter.V.NotationGroupV"...>
...
<Grid Background="{Binding BackgroundColor, Mode=OneWay}">
...
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" SharedSizeGroup="Mid"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
...
</Grid>
...
當你想通,NotationGroupV
是在BarV
UserControl
集合,BarV
由SectionV
作爲兩個擁有。 (SectionV
也用作其父控件的收集成員)
問題出在NotationGroupV
的中心行高度上,其中SharedSizeGroup="Mid"
。我想分享給應用程序中的夥伴NotationGroupV
。
所以,基本上,我想分享SharedSizeGroup
到其他NotationGroupV
在不同的父母。
任何人都知道如何公開SharedSizeGroup
這種方式?
(請隨意澄清)
謝謝。
P.S.在這個link中,解釋瞭如何在不同的網格中共享它們,但是在相同的xaml中。
儘管我無法確定您的需求是否可行,但我可以確認,只要您將'Grid.IsSharedSizeScope'附加屬性設置爲'True'的父容器控件* Grid's,你已經設置了'SharedSizeGroup's,那麼它*應該*工作。爲了找到答案,只需嘗試一下......你可能已經比自己寫這個問題的時間更快地測試過了。 – Sheridan 2014-10-09 13:14:58
@Sheridan謝謝你的回覆。但是父容器沒有這樣的網格。NotationGroupV擁有這樣的網格,僅由BarV擁有,BarV由父控制擁有。因此,只有NotationGroupV具有SharedSizeScope =「Mid」。我已經嘗試過,只是我不確定「嘗試」你和我的意思是一樣的。你能詳細解釋一下嗎? – 2014-10-09 13:22:40
您應該能夠在*不同網格的任何公共祖先*上設置'Grid.IsSharedSizeScope';它們不必位於同一個文件中,因爲該屬性是在運行時進行評估的。網格不共享一個共同的祖先(父母控制)嗎? – 2014-10-09 13:41:39