Force a custom WPF Control to resize correctly

前端 未结 4 1552
清酒与你
清酒与你 2020-12-16 05:13

I have written a WPF user control and part of it involves dynamically adding elements to a canvas which effects the height of said canvas. The canvas is nested within a grid

4条回答
  •  悲哀的现实
    2020-12-16 05:51

    You need to override MeasureOverride method of your control and return your desired size (the size of your canvas) from there. Then the parent control would resize itself to accommodate it's child (if it can).

提交回复
热议问题