Johniek Comp
Johniek Comp

Reputation: 443

Resize window (in center screen) wpf

i need open in all work area

this.Width = SystemParameters.WorkArea.Width;
this.Height = SystemParameters.WorkArea.Height;

but, window not center location in the screen, how i can location my window in center screen?

Upvotes: 1

Views: 1494

Answers (3)

Pilli
Pilli

Reputation: 171

write like this . WindowStartupLocation="CenterScreen">

Upvotes: 1

Nacho
Nacho

Reputation: 962

Try this WindowStartupLocation

UPDATED

If I use...

public MainWindow() {
    InitializeComponent();
    this.Width = SystemParameters.WorkArea.Width;
    this.Height = SystemParameters.WorkArea.Height;
    this.Top = 0;
    this.Left = 0;
}

Without WindowStartupLocation, the window is centered and fills the screen

Upvotes: 0

Nikhil Agrawal
Nikhil Agrawal

Reputation: 48558

Use WindowState

In XAML

<Window WindowState="Maximised">
// ...
</Window>

In Code-behind

MyWindow mw = new MyWindow();
mw.WindowState = WindowState.Maximised;

Upvotes: 1

Related Questions