1

所以,我有 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>
...

如您所想,NotationGroupVUserControlin的集合BarVBarV并由SectionV两个 of 拥有。(SectionV也用作其父控件的集合成员)

问题在于 的中心行高度NotationGroupV,它具有SharedSizeGroup="Mid"。我想把它分享给NotationGroupV应用程序中的伙伴。

所以,基本上,我想分享SharedSizeGroupNotationGroupV不同父母的其他人。

有谁知道如何暴露SharedSizeGroup这种方式?

(请问有什么要澄清的)

谢谢你。

PS 在这个链接中,它解释了如何在不同的网格中共享它们,但在同一个 xaml 中。

4

1 回答 1

4

虽然我无法确定您的要求是否可行,但我可以确认,只要您将Grid.IsSharedSizeScopeAttached Property设置为您为其设置的两个s的True父容器控件,那么它应该可以工作。要确定答案,请尝试一下……您自己测试它的速度可能比您写这个问题所花费的时间要快。GridSharedSizeGroup

如果此刻没有父容器控件,就加一个....(把所有东西都放进去)。这里要注意的重要一点是,您应该只在一个父容器控件上设置Grid.IsSharedSizeScope为,而不是在每个.TrueGrid

于 2014-10-09T15:53:14.020 回答