SharedSizeGroup到不同父控件中的不同Grid

Mos*_*ico 2 c# wpf xaml user-controls sharedsizegroup

所以,我有 3 个用户控件:

1.第五节.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>
...
Run Code Online (Sandbox Code Playgroud)

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>
...
Run Code Online (Sandbox Code Playgroud)

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>
...
Run Code Online (Sandbox Code Playgroud)

正如您所想到的,是inNotationGroupV的集合,并且由 2拥有。(也用作其父控件的集合成员)UserControlBarVBarVSectionVSectionV

问题在于 的中心行高度NotationGroupV,其中有SharedSizeGroup="Mid"NotationGroupV我想与应用程序中的其他人分享。

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

有谁知道如何曝光SharedSizeGroup这种方式吗?

(有什么问题请澄清)

谢谢。

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

She*_*dan 5

虽然我无法确定您的要求是否有效,但我可以确认,只要您将Grid.IsSharedSizeScope附加属性设置为您已为其设置的两个s的True父容器控件,那么它应该GridSharedSizeGroup有效。为了确定答案,只需尝试一下......您可能可以比您写这个问题所花费的时间更快地亲自测试它。

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