【问题标题】:Get Size of Window when is Maximized in WPF在 WPF 中最大化时获取窗口的大小
【发布时间】:2011-12-07 11:12:12
【问题描述】:

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

任何想法如何获得绝对值?

非常感谢。

【问题讨论】:

    标签: wpf window size maximize-window


    【解决方案1】:

    这个呢:

    <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 属性。

    【讨论】:

      【解决方案2】:

      ActualWidth 也会在最大化状态下为您提供宽度。

      【讨论】:

        【解决方案3】:

        使用ActualWidth,而不是Width

        【讨论】:

          猜你喜欢
          • 2015-07-21
          • 2011-05-22
          • 1970-01-01
          • 2012-02-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多