Always run WPF App in Maximized View

I have been playing around with WPF Applications and one of the annoying things about WPF as well as Windows Forms is that they always open up in a Normal View (which is like a Restored View) and you have to maximize it to have a full view of your application. I know this is a simple setting right from the VB Days and was wondering where to set it up in case of WPF.

The solution was to just to add the following line of code under the “InitializeComponent()” call in your Window1.xaml.cs or whatever is the startup Window.

      InitializeComponent();

      this.WindowState = WindowState.Maximized;

I am sure there are different ways to achieve this and it can be set at the configuration level etc., But this post is just for simply doing it quickly.  

If there are caveats, best practices, please post in the comments..

Cheers !!!

Print | posted on Wednesday, December 17, 2008 6:16 PM

Comments on this post

# re: Always run WPF App in Maximized View

Requesting Gravatar...
At first glance, it could seems as 'this is simple, but why as Post'.

But really at time of need, we can realize.

Nice Info.
Left by Muruganantham Durairaj on Dec 23, 2008 11:15 PM

# re: Always run WPF App in Maximized View

Requesting Gravatar...
But really at time of need, we can realize.
Left by خواطر قصيره on Nov 03, 2010 1:13 PM

# re: Always run WPF App in Maximized View

Requesting Gravatar...
It could also be done in XAML in the Window-Tag, using the WindowState Attribute - which may be better practice.
Left by BBrain on Jul 18, 2011 5:55 PM

# re: Always run WPF App in Maximized View

Requesting Gravatar...
WPF:

<Window ........
xmlns:......
WindowState=Maximized
/>
Left by Greg on Aug 10, 2011 10:26 PM

# re: Always run WPF App in Maximized View

Requesting Gravatar...
Hi,
i have .xaml page named LoginView.xaml
But its not a exact User Control, this xaml page inherits to MvxWpfView & also MvxwpfView inherits inherits to User Control finally. & this is the start up page for me.
As Top of xaml Page like this & continuos on:
<views:MvxWpfView
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" .....

My question is How can I maximize the MvxWpfView window / User control on the startup, i am not sure that much this is User Control or what.

Need Help,
Regards,
Praveen M
Left by Praveen M on Feb 15, 2016 6:25 PM

Your comment:

 (will show your gravatar)