如何:自动调整窗口大小以适合其内容

更新:2007 年 11 月

此示例演示如何设置 SizeToContent 属性以指定调整窗口大小以适合其内容的方式。

示例

// Manually alter window height and width
this.SizeToContent = SizeToContent.Manual;

// Automatically resize width relative to content
this.SizeToContent = SizeToContent.Width;

// Automatically resize height relative to content
this.SizeToContent = SizeToContent.Height;

// Automatically resize height and width relative to content
this.SizeToContent = SizeToContent.WidthAndHeight;