3

By using a wrap panel in WPF you can arrange items horizontaly.

Example here : WPF Tutorial | Wrap Panel

Now I want to space items equaly in order to fill the whole width. Like text justify, but items instead of words. How can I achieve this ?

Edit : I show you what I have actually :

enter image description here

I pick countries in the bottom list, and display selected countries in border within a wrappanel.

I want to adjuste automatically space between borders to get Spain and Thailand justified to right like Singapour.

Avlin
  • 500
  • 4
  • 20

1 Answers1

2

The only way that I can think of that you can do that in WPF is for you to create a new custom Panel class. You could use this Panel as the ItemsPanelTemplate in a collection control like this:

<ListBox ItemsSource="{Binding YourCollection}">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <YourXmlNamespacePrefix:YourJustifyPanel />
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
</ListBox>

You can find out to create a custom Panel from the following links:

How to create a Custom Layout Panel in WPF
Creating Custom Panels In WPF

It will be challenging, but it is possible. Unfortunately, there is no easy option for this requirement. Good luck.

Sheridan
  • 68,826
  • 24
  • 143
  • 183