Resize list contents to fit list sizes

I am trying to resize the contents of my list to fit the list itself. This is done in WPF.

Any ideas on how this is possible?

+3
source share
1 answer

I assume that when you say β€œresize”, you mean that you want to stretch the elements in both directions. To use the default ListBox and stretch the elements horizontally, you need to:

<ListBox HorizontalContentAlignment="Stretch"/>

The default value is Left, so all ListBoxItems are inserted to the left and are individually sized depending on their contents.

StackPanel, , . - UniformGrid, - , , . VerticalContentAlignment ( Center). , , :

<ListBox HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <UniformGrid Columns="1"/>
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
</ListBox>
+5

Source: https://habr.com/ru/post/1734181/


All Articles