在这种组合中,gridsplitter 将我的列表视图推到视野之外时,我遇到了问题。重现步骤:
- 启动程序,拖动窗口大小变大
- 将红色拆分器一直向左拖动以最小化蓝色列
- 加宽两个 ListView 列,直到它们位于视口之外并出现水平滚动
- 再次将窗口大小拖小
对我来说,这会慢慢地将 ListView 推到 Window 之外。请注意,ScrollViewer 实际上随着 Window 的大小而减小,但速度不同,并且会慢慢消失。一旦滚动查看器开始滑出视图,拆分器就不能再使用了!
奇怪的是,如果我不首先最小化左侧面板,我不会得到这种行为!
有什么办法可以解决这个问题?
<Window x:Class="LayoutTest3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="600" Width="800" MinHeight="600" MinWidth="800" >
<Window.Resources>
<XmlDataProvider XPath="/Celebrities/Celebrity" x:Key="celebs">
<x:XData>
<Celebrities xmlns="">
<Celebrity Name="Jimmy">
<LastName>Page</LastName>
</Celebrity>
<Celebrity Name="Johnny">
<LastName>Depp</LastName>
</Celebrity>
<Celebrity Name="Britney">
<LastName>Spears</LastName>
</Celebrity>
</Celebrities>
</x:XData>
</XmlDataProvider>
<DataTemplate x:Key="NameTemplate">
<TextBlock Text="{Binding XPath=@Name}" />
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="100" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" MinWidth="400" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" Background="Blue" />
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Center" ResizeBehavior="PreviousAndNext" VerticalAlignment="Stretch" Background="Red" />
<Border Grid.Column="2" Background="Green">
<ListView ItemsSource="{Binding Source={StaticResource celebs}}">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn Header="Name" CellTemplate="{StaticResource NameTemplate}" Width="150" />
<GridViewColumn Header="LastName" DisplayMemberBinding="{Binding XPath=LastName}" />
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
</Border>
</Grid>
</Window>