因此,我有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是BarV中的UserControl的集合,而BarV作为其中的两个被SectionV拥有。(SectionV也用作其父控件的集合成员)
问题在NotationGroupV的中间行高度上,它有SharedSizeGroup="Mid"。我想把它分享给应用程序中的NotationGroupV伙伴。
所以,基本上,我想把SharedSizeGroup分享给不同父母的其他NotationGroupV。
有人知道如何以这种方式公开SharedSizeGroup吗?
(请澄清任何问题)
谢谢。
在这个链接中,它解释了如何在不同的网格中共享它们,但是在相同的xaml中。
发布于 2014-10-09 15:53:14
虽然我不能确定您的需求是否有效,但我可以确认,只要您将Grid.IsSharedSizeScope附加属性设置为True,那么您就可以在设置了SharedSizeGroups的两个Grid的父容器控件上设置SharedSizeGroup附加属性。要确定的话,就试一试.你可能会比写这个问题所花的时间更快地测试它。
如果目前没有父容器控制,只需添加一个..。(把所有东西都放进去)。这里需要注意的是,您应该只在一个父容器控件上将Grid.IsSharedSizeScope设置为True,而不是在每个Grid上。
https://stackoverflow.com/questions/26279010
复制相似问题