user1040567
user1040567

Reputation: 137

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.

Upvotes: 3

Views: 8715

Answers (3)

Markus
Markus

Reputation: 4577

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.

Upvotes: 6

Prafulla
Prafulla

Reputation: 1949

Use ActualWidth, instead of Width.

Upvotes: 6

HCL
HCL

Reputation: 36785

ActualWidth will give you the width also in maximized state.

Upvotes: 6

Related Questions