控件显示在GridSplitter下面
本文关键字:下面 GridSplitter 显示 控件 | 更新日期: 2023-09-27 18:11:04
我有一个GridSplitter在我的应用程序和ListView控件总是出现在Splitter下面。我如何使ListView控件适合在 GridSplitter的左边部分的边界内,而不强制在ListView上固定宽度?
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Grid Margin="0, 25, 0, 22">
<ScrollViewer ScrollViewer.CanContentScroll="True" VerticalScrollBarVisibility="Auto">
<ListView x:Name="list" ItemsSource="{Binding Messages}" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<DataTemplate>
<ListViewItem>
<TextBlock Text="sd" />
</ListViewItem>
</DataTemplate>
</ListView>
</ScrollViewer>
</Grid>
<GridSplitter Width="5" HorizontalAlignment="Right" VerticalAlignment="Stretch" Background="#FFCFE5F0" Margin="0, 25, 0, 22" />
</Grid>
放到列中
<Grid Margin="0, 25, 0, 22" Grid.Column = 0
<GridSplitter Grid.Column = 1
将GridSplitter
添加到相应的列中。试试这个:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Grid>
<ScrollViewer ScrollViewer.CanContentScroll="True" VerticalScrollBarVisibility="Auto">
<ListView x:Name="list" ItemsSource="{Binding Items}" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<DataTemplate>
<ListViewItem>
<TextBlock Text="sd" />
</ListViewItem>
</DataTemplate>
</ListView>
</ScrollViewer>
</Grid>
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Right" VerticalAlignment="Stretch" Background="#FFCFE5F0" Margin="0, 25, 0, 22" />
</Grid>