Share via


Page.WindowWidth 属性

定义

获取或设置 Window 的宿主 NavigationWindowPage 的宽度。

public:
 property double WindowWidth { double get(); void set(double value); };
public double WindowWidth { get; set; }
member this.WindowWidth : double with get, set
Public Property WindowWidth As Double

属性值

直接承载 Page 的窗口的宽度。

示例

以下示例演示如何从页面设置窗口的宽度。

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

注解

WindowWidth 仅当 由窗口直接承载时 Page 应用,其中包括:

Page如果 由 Frame承载,设置WindowWidth不起作用,但你仍然可以获取 的值WindowWidth

Page XAML 浏览器应用程序中 (XBAP) 只能使用 WindowWidth 来更改浏览器的宽度;不能通过设置 WidthMinWidthMaxWidth来更改宽度。

有关 XBAP 支持的详细信息,请参阅 有关 WPF 浏览器托管的应用程序的常见问题 (XBAP)

Windows Internet Explorer 窗口的最小宽度为 250 像素。 对于浏览器承载的页面,这意味着 如果 的值会导致 Windows Internet Explorer 窗口的总宽度小于 250 像素,则可能不会应用 值 WindowWidth

适用于