How to make the StackPanel or DockPanel stretch to fit their containers in WPF?

前端 未结 1 1441
半阙折子戏
半阙折子戏 2021-02-13 02:59

I have a Grid as a root container with two columns defined (There\'s only one row).
The first column has flexible width and second column has 300px fixed width.

相关标签:
1条回答
  • 2021-02-13 03:42

    You can make the Content of every ListBoxItem stretch by setting HorizontalContentAlignment in the ItemContainerStyle

    <ListBox ...>
        <ListBox.ItemContainerStyle>
            <Style TargetType="ListBoxItem">
                <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
            </Style>
        </ListBox.ItemContainerStyle>
    
    0 讨论(0)
提交回复
热议问题