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

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

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

Your comment:

 (will show your gravatar)