WPF错误? Grid的列不支持ListBox滚动条

时间:2009-08-21 17:51:33

标签: wpf grid resize

在以下示例中,最左侧列的宽度不会增加,以适应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中的错误吗?

1 个答案:

答案 0 :(得分:1)

看来这是a known bug with the ListBox scrollbar and the WPF Grid。微软还指出,他们可能不会在4.0中修复此问题。