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

use*_*567 1 size wpf window maximize-window

我搜索一种获得最大化WPF窗口的宽度属性的方法.

任何想法我怎样才能获得绝对价值?

非常感谢.

Pra*_*lla 6

使用ActualWidth, 代替Width.


HCL*_*HCL 5

ActualWidth也会以最大化状态为您提供宽度.


Mar*_*kus 5

那这个呢:

<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>
Run Code Online (Sandbox Code Playgroud)

只需使用该ActualWidth物业.