Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在WPF中最大化时获取窗口大小_Wpf_Window_Size_Maximize Window - Fatal编程技术网

在WPF中最大化时获取窗口大小

在WPF中最大化时获取窗口大小,wpf,window,size,maximize-window,Wpf,Window,Size,Maximize Window,我寻找一种方法来获得最大化WPF窗口的宽度属性 你知道我怎样才能得到绝对值吗 非常感谢。使用实际宽度,而不是宽度使用实际宽度,而不是宽度,将使宽度也处于最大化状态。将使宽度也处于最大化状态。如何: <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2

我寻找一种方法来获得最大化WPF窗口的宽度属性

你知道我怎样才能得到绝对值吗


非常感谢。

使用
实际宽度
,而不是
宽度

使用
实际宽度
,而不是
宽度

将使宽度也处于最大化状态。

将使宽度也处于最大化状态。

如何:

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Label Content="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}, Mode=FindAncestor}, Path=ActualWidth}"></Label>
    </Grid>
</Window>

只需使用
ActualWidth
属性。

这是怎么回事:

<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Label Content="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}, Mode=FindAncestor}, Path=ActualWidth}"></Label>
    </Grid>
</Window>

只需使用
ActualWidth
属性即可