3

i search for a way to get the Width-Property of an Maximized WPF Window.

Any Ideas how can i get the absolute value?

Thanks a lot.

user1040567
  • 137
  • 2
  • 9

3 Answers3

6

Use ActualWidth, instead of Width.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Prafulla
  • 1,929
  • 1
  • 17
  • 21
6

ActualWidth will give you the width also in maximized state.

HCL
  • 36,053
  • 27
  • 163
  • 213
6

What about this:

<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>

Just use the ActualWidth property.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Markus
  • 4,487
  • 3
  • 41
  • 51