折叠堆栈面板时从网格中删除空间
本文关键字:网格 删除 空间 堆栈 折叠 | 更新日期: 2023-09-27 18:37:28
>我有一个应用程序,我可以在网格中显示堆栈面板行。用户可以隐藏堆栈面板行以"清理"网格,并且仅查看/编辑他们想要的内容,其想法是折叠分隔器之间的堆栈面板和关闭之间的空间。
当我将堆栈面板设置为可见性.折叠时,堆栈面板消失了,但它们占用的空间仍然存在。
如何消除差距?(我添加了更新布局,但这似乎没有任何作用)
之前的样子:之前
之后的样子:之后
我的 XAML:
<ScrollViewer Name="scroll" PanningMode="Both" Grid.Column="0" Grid.Row="1">
<ScrollViewer.Resources>
<sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">50</sys:Double>
<sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarButtonHeightKey}">50</sys:Double>
</ScrollViewer.Resources>
<Grid x:Name="RecipeEditorCtrl" VerticalAlignment="Top">
</Grid>
</ScrollViewer>
我的 C#:
...
int rowIndex = Grid.GetRow(CNtmp);
rowIndex++;
tmpCN = (CollectionNode)RecipeEditorCtrl.Children[rowIndex];
while (tmpCN.dataType.Text != "SEPERATOR")
{
tmpCN.Visibility = Visibility.Collapsed;
rowIndex++;
tmpCN = (CollectionNode)RecipeEditorCtrl.Children[rowIndex];
}
RecipeEditorCtrl.UpdateLayout();
}
您可以使用RowsDefinitions
和将每个RowDefinition
Height
属性添加到Auto
然后将StackPanel
添加到这些行中