tags:

views:

228

answers:

1

In the following example, the leftmost column's width does not increase to accommodate the ListBox's scrollbar that appears when the UserControl's height is decreased:

<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>

When the TextBlock with the ColumnSpan attribute is removed the column resizes as expected. Is this a bug in WPF?

+1  A: 

It appears this is a known bug with the ListBox scrollbar and the WPF Grid. Microsoft also notes they will probably not have this fixed in 4.0.

sixlettervariables
The search function at connect.microsoft.com would not find this bug, funny enough Google found it for me without much trouble.
sixlettervariables
yes they suck i definitely agree
Shimmy