gpt4 book ai didi

wpf - 获取网格的中间行以填充可用空间

转载 作者:行者123 更新时间:2023-12-04 16:11:49 25 4
gpt4 key购买 nike

我已经为此经历了很多示例代码,最后决定问这个:我有一个网格,其中有一个固定位置的按钮和另一个网格。外部网格没有设置宽度/高度。它应该根据显示分辨率而改变。我将窗口的 W/H 设置为:

Width = 200;
Height = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height - 5;

在内部网格内我有 3 行,上面的一行是一个按钮(高度自动),中间的是一个 ListView ,它的高度可能会有所不同(并且必须填充可用空间),最后一行由一个文本框组成,它应该始终停留在窗口底部。 xaml 如下:
<Button Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" Click="Button_Click" Width="32" Height="32" FontSize="16" VerticalAlignment="Center" 
HorizontalAlignment="Left" FontWeight="Bold" ToolTip="Click here to hide the Sidebar">&gt;</Button>
<Grid VerticalAlignment="Top" Background="Transparent" Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<!-- This is the settings bar-->
<RowDefinition Height="*" />
<!-- This will contain the listbox-->
<RowDefinition Height="Auto" />
<!-- This is to maintain vertical arrangement and future use-->
</Grid.RowDefinitions>

<Button Content="hello" Grid.Row="0" />
<ListView x:Name="lstView" Background="Transparent" Grid.Row="1"/>
<TextBox TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="50" Margin="2" BorderBrush="Black" Grid.Row="2" />`

但我只是无法让中间行填满整个空间和在屏幕底部对齐的文本框。任何人都可以建议如何将文本框与底部和中间行对齐以填充整个剩余高度,以及如何在更改显示模式时不明确设置高度的情况下完成此操作?

最佳答案

如果不告诉Grid要占用它无法分配的所有可用空间,您可能应该设置 VerticalAlignmentGridStetch .

关于wpf - 获取网格的中间行以填充可用空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12227215/

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