Wpf control size to content?

后端 未结 4 1223
旧巷少年郎
旧巷少年郎 2020-12-13 12:11

How do I make a WPF control to change its size according the content in it?

4条回答
  •  Happy的楠姐
    2020-12-13 12:32

    For most controls, you set its height and width to Auto in the XAML, and it will size to fit its content.

    In code, you set the width/height to double.NaN. For details, see FrameworkElement.Width, particularly the "remarks" section.

提交回复
热议问题