Search code examples
wpfwindowsizemaximize-window

Get Size of Window when is Maximized in WPF


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.


Solution

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