0

I'm trying to display a window with a border like with WindowStyle="None" (picture 2), but without the option to resize it!

When I set the ResizeMode="NoResize" the border disappears (picture 1)

enter image description here

Does anyone know how to do this?

Xenogenesis
  • 390
  • 4
  • 23
  • possible duplicate of this: http://stackoverflow.com/questions/3386486/wpf-make-window-unresizeable-but-keep-the-frame – r wank Jul 02 '15 at 08:10
  • Your assumptions are completly wrong. WindowStyle="None" makes your border disappear, like in picture 1. ResizeMode="NoResize" disables all options to resize the window, IF a border is present. – r wank Jul 02 '15 at 08:19
  • @rwank Mmmh, nope, `WindowStyle="None"` doesn't make your border disappear UNLESS you set `ResizeMode="NoResize"`. @Xenogenesis is right. But it is indeed a duplicate, though. – almulo Jul 02 '15 at 08:37
  • @almulo yea you are right. my bad. – r wank Jul 02 '15 at 08:40
  • @rwank Thanks, I wasn't able to find a related question, maybe I was to fixed upon the 'Window' wording except using 'Frame' @almulo Hello again, you're right, with no ResizeMode specified and `None` as WindowStyle there is a border – Xenogenesis Jul 02 '15 at 08:41

1 Answers1

0

You can get around this by setting the Max and Min size properties to the same values, thus forcing the Window to have a fixed size. Something like this should work:

Window w = new Window();
w.MaxHeight = w.MinHeight = 300;
w.MinWidth = w.MaxWidth = 400;
w.WindowStyle = System.Windows.WindowStyle.None;
w.Show();
Master_T
  • 7,232
  • 11
  • 72
  • 144
  • I agree on the fixed size and the border, but the resize cursor is still showing => Some users would be annoyed by that – Xenogenesis Jul 03 '15 at 07:39
  • 1
    The window's border (the so called "chrome") is part of Win32 rather than WPF, so I don't think you can change it directly in pure WPF. A solution, at this point, would be to use NoResize and then draw your own border around the window. – Master_T Jul 03 '15 at 11:39