Synchronizing WPF control widths in a WrapPanel

前端 未结 3 631
悲&欢浪女
悲&欢浪女 2021-01-19 11:21

I have this case


    Really long name
    Short
    Longe         


        
3条回答
  •  一生所求
    2021-01-19 12:12

    The best way to do this is to use a CustomControl like the article you posted.

    Any solution you come across is going to have to iterate through the list of items and find the maximum width during the measure phase.

    Any sort of XAML-only answer would have to be provided OOTB (e.g. IsSharedSizeScope), or would leverage some sort of multi-binding to link the items together. Thus any sort of XAML answer would be full of markup which makes it more verbose (and less elegant).

    The only modification that I see to the CodeProject article you posted is adding the ability to "turn-off" consideration of certain elements (like your slider). This could be done as an additional attached property.

提交回复
热议问题