Converting Grid Layout

前端 未结 1 1750
生来不讨喜
生来不讨喜 2021-01-26 11:52

I\'m somewhat new to WPF, so forgive me if this is trivial.

I have a panel set up like the following image suggest:

相关标签:
1条回答
  • 2021-01-26 12:45

    I would recommend that you use a UniformGrid control. From the linked page:

    Provides a way to arrange content in a grid where all the cells in the grid have the same size.

    Furthermore, it has a Columns property which enables you to set the number of columns that are in the grid.

    <ListBox ItemsSource="{Binding Items}">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <UniformGrid Columns="5" />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
    </ListBox>
    

    You can find out more about the various Panels used in WPF from the Panels Overview page on MSDN.

    0 讨论(0)
提交回复
热议问题