在WPF中最大化时获取窗口大小
我寻找一种方法来获得最大化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
非常感谢。使用
实际宽度
,而不是宽度使用实际宽度
,而不是宽度
,将使宽度也处于最大化状态。将使宽度也处于最大化状态。如何:
<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
属性即可