首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不同父控件中不同网格的SharedSizeGroup

不同父控件中不同网格的SharedSizeGroup
EN

Stack Overflow用户
提问于 2014-10-09 12:56:49
回答 1查看 1.2K关注 0票数 1

因此,我有3个用户控件:

1. SectionV.xaml

代码语言:javascript
复制
<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

代码语言:javascript
复制
<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

代码语言:javascript
复制
<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>
...

正如您所理解的,NotationGroupVBarV中的UserControl的集合,而BarV作为其中的两个被SectionV拥有。(SectionV也用作其父控件的集合成员)

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

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

有人知道如何以这种方式公开SharedSizeGroup吗?

(请澄清任何问题)

谢谢。

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-09 15:53:14

虽然我不能确定您的需求是否有效,但我可以确认,只要您将Grid.IsSharedSizeScope附加属性设置为True,那么您就可以在设置了SharedSizeGroups的两个Grid的父容器控件上设置SharedSizeGroup附加属性。要确定的话,就试一试.你可能会比写这个问题所花的时间更快地测试它。

如果目前没有父容器控制,只需添加一个..。(把所有东西都放进去)。这里需要注意的是,您应该只在一个父容器控件上将Grid.IsSharedSizeScope设置为True,而不是在每个Grid上。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26279010

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档