Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to stop a user from resizing the top-level window of an application written in WPF?

Tags:

wpf

size

resize

What is the best way to stop a user from resizing the top-level window of an application written in WPF?

like image 540
Thomas Bratt Avatar asked Nov 10 '08 16:11

Thomas Bratt


People also ask

What is WindowChrome in WPF?

The WindowChrome class separates the functionality of the window frame from the visuals, and lets you control the boundary between the client and non-client areas of your application window. The WindowChrome class lets you put WPF content in the window frame by extending the client area to cover the non-client area.

How to display dialog box in WPF?

First of all, create a new WPF project with the name WPFDialog. Drag one button and one textbox from the Toolbox. When the user clicks this button, it opens another dialog box with Yes, No, and Cancel buttons and displays a message “click any button” on it.


2 Answers

You will want to use the ResizeMode.NoResize on the window.

<Window x:Class="WpfApplication5.Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     ResizeMode="NoResize"> </Window> 
like image 133
Todd White Avatar answered Sep 21 '22 10:09

Todd White


A WPF quirk to note is that if ResizeMode="NoResize" and WindowStyle="None" you will lose the chrome around the entirely in Vista Aero.

like image 21
Rob Sobers Avatar answered Sep 20 '22 10:09

Rob Sobers