gpt4 book ai didi

c# - SharedSizeGroup 到不同父控件中的不同 Grid

转载 作者:太空宇宙 更新时间:2023-11-03 21:27:16 26 4
gpt4 key购买 nike

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

如你所想,NotationGroupVBarVUserControl的集合,BarV归属于SectionV 作为两个。 (SectionV 也用作其父控件的集合成员)

问题出在 NotationGroupV 的中心行高上,它具有 SharedSizeGroup="Mid"。我想将它分享给应用程序中的其他 NotationGroupV

所以,基本上,我想将 SharedSizeGroup 共享给不同父级中的其他 NotationGroupV

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

(请问任何澄清)

谢谢。

附言在这个link ,它解释了如何在不同的网格中共享它们,但在同一个 xaml 中。

最佳答案

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

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

关于c# - SharedSizeGroup 到不同父控件中的不同 Grid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26279010/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com