Question

Is there a way to make all item in WrapPanel alignment to center?

WrapPanel Normal Behavior

|1234567  |
|890      |

Desired Behavior

| 1234567 |
|   890   |

Possible duplicate link

I just don't understand how to use the code on the answer (on link).

Was it helpful?

Solution

The link is a custom WrapPanel. just copy it into an empty class and be sure to set all the using classes at the first lines.

Use this custom panel as you use a normal WrapPanel. (in Xaml is a little bit different). in this panel there is an extra propert: HorizontalContentAlignment. Its default value is HorizontalAlignment.Left. You should set HorizontalAlignment=HorizontalAlignment.Center.

There is no need to deal with MeasureOverride or ArrangeOverride methods.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top