Raj
Raj

Reputation: 361

Lock window size to maximize in WPF

How do I restrict my WPF window to only permit the maximize and minimize functions. In my application, users should not be allowed to Resize the window.

I changed my WPF window properties as per below:

Window State: Maximize

Resize Mode: NoResize

When I run my application window open in maximize view, but when I double click on the window border it Resizes. Is it possible to restrict this behavior?

Upvotes: 2

Views: 11694

Answers (1)

Furqan Safdar
Furqan Safdar

Reputation: 16698

With this piece of code Window will open in Maximized state and can be Minimized as well with No Resize. You can also specify some fixed size (Height and Width) to windows if you want like.

Height="350" Width="525" 

Xaml:

<Window 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     WindowState="Maximized" ResizeMode="CanMinimize">    
...    
</Window>

Refer to Resize Mode section in MSDN Reference: http://msdn.microsoft.com/en-us/library/ms748948.aspx

You can refer to somewhat similar post: Minimize window with NoResize mode on

Upvotes: 1

Related Questions