WPF:网格行按网格拆分器的相反方向缩放
在我的WPF应用程序中,我有一个XAML窗口,其中包括自动调整标题、子标题和广告页脚的大小,在它们之间,我有其他区域可以填充剩余的空间WPF:网格行按网格拆分器的相反方向缩放,wpf,Wpf,在我的WPF应用程序中,我有一个XAML窗口,其中包括自动调整标题、子标题和广告页脚的大小,在它们之间,我有其他区域可以填充剩余的空间 中间有一个网格分割器,允许用户对屏幕的不同部分进行大小调整。 现在,由于一些奇怪的未知原因,当我移动拆分器时,底部刻度上的一个自动调整大小的部件与拆分器的方向相反 以下XAML代码是用于重现问题的测试布局: <Window x:Class="TestWpfApp.MainWindow" xmlns="http://schemas.microsoft
中间有一个网格分割器,允许用户对屏幕的不同部分进行大小调整。
现在,由于一些奇怪的未知原因,当我移动拆分器时,底部刻度上的一个自动调整大小的部件与拆分器的方向相反 以下XAML代码是用于重现问题的测试布局:<Window x:Class="TestWpfApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="5" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="CornflowerBlue">
<TextBlock>Title</TextBlock>
</Border>
<Border Grid.Row="1" Background="LightSkyBlue">
<TextBlock>Sub-title</TextBlock>
</Border>
<Border Grid.Row="2">
<TextBlock>Auto sizing element</TextBlock>
</Border>
<GridSplitter Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Center" Height="5" />
<Border Grid.Row="4" Background="CornflowerBlue">
<TextBlock>Header</TextBlock>
</Border>
<Border Grid.Row="5">
<TextBlock>Auto sizing element</TextBlock>
</Border>
<Border Grid.Row="6" Background="LightSkyBlue">
<TextBlock>Footer</TextBlock>
</Border>
</Grid>
标题
副标题
自动调整尺寸元件
标题
自动调整尺寸元件
页脚
有人知道为什么会发生这种情况吗?GridSplitter会影响其顶部和底部元素。您现在有两个边框,它们之间有GridSplitter,所以它将在这些元素之间“拉伸”。它不知道您想要在两个“自动调整大小元素”之间拉伸。它只会在放置它的两个元素之间调整大小 我认为这是你想要的:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="5" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Grid.Row="0" Background="CornflowerBlue">
<TextBlock>Title</TextBlock>
</Border>
<Border Grid.Row="1" Background="LightSkyBlue">
<TextBlock>Sub-title</TextBlock>
</Border>
<Border Grid.Row="2">
<TextBlock>Auto sizing element</TextBlock>
</Border>
<GridSplitter Grid.Row="3" HorizontalAlignment="Stretch" Height="5" />
<Border Grid.Row="4">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Background="CornflowerBlue" Grid.Row="0">
<TextBlock>Header</TextBlock>
</Border>
<TextBlock Grid.Row="1">Auto sizing element</TextBlock>
</Grid>
</Border>
<Border Grid.Row="5" Background="LightSkyBlue">
<TextBlock>Footer</TextBlock>
</Border>
</Grid>
标题
副标题
自动调整尺寸元件
标题
自动调整尺寸元件
页脚
谢谢。这是有道理的。