In WPF Stretch a control to fill a ListView Column

前端 未结 3 1834

How do I make a control fill the whole cell in a ListView (with a GridView)? I\'ve played around with various properties, but the control is always it\'s minimum size.

3条回答
  •  一个人的身影
    2020-12-29 04:46

    Your user control specifies the values for the "Height" and "Width" properties. Nothing is allowed to override properties you have explicitly set. Remove "Height" and "Width" and the control's container will be able to mess with the size.

    You might want to set a reasonable "MinHeight" and "MinWidth" to prevent containers from squishing you.

    Different containers do different things to your control's size; for example, Grid expands you to fill the grid cell you're in, while StackPanel shrinks you to your minimum size. So you might need to deal with that too.

提交回复
热议问题