C
C#13mo ago
palusi

❔ wpf custom window

I want to design a custom window in wpf. The window should behave normally, i.e. animations, gestures, etc., but the edge of the window should be up to me. What's the best way to do this?
15 Replies
JakenVeina
JakenVeina13mo ago
it SHOULD just be a matter of finding all the styling/templating options that you want to change what you're probably wanting to know about, and where the interesting part of this is, is in the WindowChrome give this a read
JakenVeina
JakenVeina13mo ago
you can create "custom" windows in two main ways A) set WindowStyle="None", which essentially removes the chrome entirely, and requires you to implement your own minimize/maximize/close/etc functionality, if you want it B) set WindowChrome to your own custom WindowChrome subclass, where you put whatever customizations you can
palusi
palusi13mo ago
Thanks does not work with wpf i guess
SinFluxx
SinFluxx13mo ago
What makes you say it doesn't work with WPF?
palusi
palusi13mo ago
errror message: "Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand Fehler XDG0008 "WindowChrome" wird in einem Windows Presentation Foundation (WPF)-Projekt nicht unterstützt. " translated: Severity Code Description Project File Line Suppression state Error XDG0008 "WindowChrome" is not supported in a Windows Presentation Foundation (WPF) project. is it possible? i only want to change the color of the window menu border, is there any fast way to do that? @WPF
br4kejet
br4kejet13mo ago
you mean this thing?
palusi
palusi13mo ago
No
br4kejet
br4kejet13mo ago
the actual window border itself? or like an actual menu with File, Edit, etc? you should be able to set the BorderBrush property on most things
palusi
palusi13mo ago
The border above
br4kejet
br4kejet13mo ago
ah the titlebar border... yeah you have to use WindowChrome for that because it's a part of the non-client area not sure why it says it's unsupported for you though could try restarting visual studios, that usually fixes those problems worst case, create a new WPF project and it should fix it
palusi
palusi13mo ago
Tried that Didnt work
br4kejet
br4kejet13mo ago
you have .NET Framework installed right? e.g. 4.7.2 should be able to define the window chrome as something like
<WindowChrome CaptionHeight="26" ResizeBorderThickness="6" CornerRadius="0" GlassFrameThickness="1 0 0 0"
NonClientFrameEdges="None" UseAeroCaptionButtons="False" />
<WindowChrome CaptionHeight="26" ResizeBorderThickness="6" CornerRadius="0" GlassFrameThickness="1 0 0 0"
NonClientFrameEdges="None" UseAeroCaptionButtons="False" />
then you can just use a DockPanel containing a custom titlebar and the content
palusi
palusi13mo ago
just put it in the window as general item or where should i put it? i set this using a setter in a style:
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CaptionHeight="26" ResizeBorderThickness="6" CornerRadius="0" GlassFrameThickness="1 0 0 0"
NonClientFrameEdges="None" UseAeroCaptionButtons="False" />
</Setter.Value>
</Setter>
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CaptionHeight="26" ResizeBorderThickness="6" CornerRadius="0" GlassFrameThickness="1 0 0 0"
NonClientFrameEdges="None" UseAeroCaptionButtons="False" />
</Setter.Value>
</Setter>
now i have these problems: 1. in fullscreen a part of the window isn't visible 2. clicks on buttons on top of the window dont be recognized 3. the window animations for maximizing and minimizing dont play 4. By resizing the window on the right or top side it laggs How can I fix this or is there any better way to do this?
Accord
Accord13mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts