2

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).

Community
  • 1
  • 1
Reyn
  • 269
  • 5
  • 17

1 Answers1

2

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.

Ramin
  • 2,133
  • 14
  • 22