所以,我有 3 个用户控件:
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
是UserControl
in的集合BarV
,BarV
并由SectionV
两个 of 拥有。(SectionV
也用作其父控件的集合成员)
问题在于 的中心行高度NotationGroupV
,它具有SharedSizeGroup="Mid"
。我想把它分享给NotationGroupV
应用程序中的伙伴。
所以,基本上,我想分享SharedSizeGroup
给NotationGroupV
不同父母的其他人。
有谁知道如何暴露SharedSizeGroup
这种方式?
(请问有什么要澄清的)
谢谢你。
PS 在这个链接中,它解释了如何在不同的网格中共享它们,但在同一个 xaml 中。