How could I do this with wpf instead of windows forms?
Asked
Active
Viewed 5,016 times
2 Answers
7
You can do it by setting WindowChrome.
/* Set Borderless Chrome to this Window */
WindowChrome Resizable_BorderLess_Chrome = new WindowChrome();
Resizable_BorderLess_Chrome.GlassFrameThickness = new Thickness(0);
Resizable_BorderLess_Chrome.CornerRadius = new CornerRadius(0);
Resizable_BorderLess_Chrome.CaptionHeight = 5.0;
WindowChrome.SetWindowChrome(this, Resizable_BorderLess_Chrome);
Add the above code inside the window constructor to obtain border less resizable window. Or you could use the window style setter to set the window chrome property:
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CornerRadius="0" GlassFrameThickness="1" UseAeroCaptionButtons="False"/>
</Setter.Value>
</Setter>
In addition to this you need to set ResizeMode to CanResize (or CanResizeWithGrip whatever that suits your purpose) and Window Style to None.
Refer MSDN link for more information
If you are looking for Metro UI like window please check this SO Question
-
1Great. It should be noted though that this is .NET 4.5 API. – Robert Važan Mar 31 '14 at 19:30
-
You can use shell integration library to get the same functionality in .NET 4.0 . http://archive.msdn.microsoft.com/WPFShell . Though there is significant namespace changes. – kiran Apr 01 '14 at 03:33
-
Meantime I've found out that [WindowChrome](http://msdn.microsoft.com/en-us/library/microsoft.windows.shell.windowchrome.aspx) is also part of Microsoft's [Ribbon UI](http://msdn.microsoft.com/en-us/library/ff799534%28v=vs.100%29.aspx) for .NET 4 that can be [downloaded here](http://www.microsoft.com/en-us/download/details.aspx?id=11877), although only one DLL from the package is needed to get WindowChrome. – Robert Važan Apr 01 '14 at 08:03