在以下示例中,最左侧列的宽度不会增加,以适应ListBox
高度降低时显示的UserControl
滚动条:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Example">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.ColumnSpan="2">Example text</TextBlock>
<ListBox Grid.Row="1" Grid.Column="0">
<ListBoxItem>One</ListBoxItem>
<ListBoxItem>Two</ListBoxItem>
<ListBoxItem>Three</ListBoxItem>
<ListBoxItem>Four</ListBoxItem>
<ListBoxItem>Five</ListBoxItem>
</ListBox>
<Expander Grid.Row="1" Grid.Column="1" Header="Expander" />
</Grid>
</UserControl>
删除带有TextBlock
属性的ColumnSpan
时,列会按预期调整大小。这是WPF中的错误吗?
答案 0 :(得分:1)
看来这是a known bug with the ListBox scrollbar and the WPF Grid。微软还指出,他们可能不会在4.0中修复此问题。