Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-resizable windows with windowStyle=None

Tags:

c#

.net

window

wpf

Basically, I want to create a window that looks like the following: alt text http://www.thex9.net/screenshots/2009-10-15_1347.png

However, the window shouldn't be resizable (the one in the screenshot is) but must retain the glass border. The XAML for the window in the screenshot is as follows:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="WpfApplication1.MainWindow"
    x:Name="Window" Title="MainWindow" WindowStyle="None">    
 <Grid x:Name="LayoutRoot"/>
</Window>

Is it possible to create a window which looks similar to the one in my screenshot but is not resizable? Any help would be very much appreciated.

like image 984
Daniel Avatar asked Oct 15 '09 03:10

Daniel


2 Answers

Probably you can get desired result by: ResizeMode=
XAML object property which can take have following states:

  • NoResize - A window cannot be resized. The Minimize and Maximize buttons are not displayed in the title bar.
  • CanMinimize - A window can only be minimized and restored. The Minimize and Maximize buttons are both shown, but only the Minimize button is enabled.
  • CanResize - A window can be resized. The Minimize and Maximize buttons are both shown and enabled.
  • CanResizeWithGrip - A window can be resized. The Minimize and Maximize buttons are both shown and enabled. A resize grip appears in the bottom-right corner of the window.
like image 129
Wojciech Papaj Avatar answered Oct 31 '22 19:10

Wojciech Papaj


One way to accomplish a fixed size Window while retaining the border is to set the Min[Width|Height] and Max[Width|Height] properties to be the same value. The border will still show the resize cursor, but the user will not be able to change the size of the Window.

If the fact that the border still indicates that it's resizable bothers you, the next step is to set the ResizeMode="NoResize", but then you have to start drawing your own Aero glass if you want to retain the glass edges.

like image 21
Drew Marsh Avatar answered Oct 31 '22 19:10

Drew Marsh