如何:从页设置窗口的宽度

此示例演示如何从 Page 设置窗口的宽度。

示例

Page 可以通过设置 WindowWidth 来设置承载它的窗口的宽度。 使用此属性,无需明确了解承载 Page 的窗口的类型。

注意注意

若要使用 WindowWidth 来设置窗口的宽度,Page 必须为窗口的子级。

<Page
    xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
    Title="SetWindowWidthPage"
    WindowWidth="500"
    >
</Page>