I have a RibbonWindow where my WindowStyle is set to None, so what I can't understand is what have happened to the Grip to resize the window?! Even if my controls have their Margin set to 0 in the Bottom part of them will be hidden... It's a strange behaviour.
But if I change the bottom Margin of the controls it's ok, but the Grip can't be seen anyway, probably because part of the client area is hidden...
I have to say, if a have a WPF Window, this doesn't happen, it only happens with the RibbonWindow. And I am using the RibbonWindow because the Ribbon has other look in the proper window.
So what can I do to solve the problem with the Grip?
Some of my code...
<rib:RibbonWindow x:Class="MyApp.Views.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:rib="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
AllowsTransparency="True"
Background="Transparent"
Height="750"
ResizeMode="CanResizeWithGrip"
Width="1000"
WindowStartupLocation="CenterScreen"
WindowStyle="None">
<Grid Margin="0, 0, 0, 20">
<Border Background="Black"
CornerRadius="5"
Opacity="0.5"/>
</Grid>
</rib:RibbonWindow>
Thanks in advance!
This was intriguing to debug. Turns out that the style for the window has a bug: if the system is defined to have
IsGlassEnabled == true
(in Win7 Aero theme makes ittrue
) then the window relies on the Microsoft.Windows.Shell.WindowChrome (from Microsoft.Windows.Shell assembly) to draw the border and the top buttons of the window; and this WindowChrome has itsGlassFrameThickness
property set to8,30,8,8
in combination withNonClientFrameEdges
set toBottom
.What happens is that because of
AllowsTransparency == true
the glass border is transparent but the window still "cuts" its thickness from the overall window size because theWindowChrome
definesNonClientFrameEdges="Bottom"
, thus cutting theResizeGrip
from view.You can see this if you (frantically) drag the window over your screen - you'll see the
ResizeGrip
flickering.To solve this we need to define a new
WindowChrome
withNonClientFrameEdges="None"
(orGlassFrameThickness = 0
or both) and assign it to the window only whenIsGlassEnabled == true && AllowsTransparency == true
(I'm using application resources defined in App.xaml and defining onlyNonClientFrameEdges="None"
):The
DataTrigger
is almost as is from the original style, with only one modification: I've commented the setter for the WindowChrome.The
MultiDataTrigger
s are my addition. They check the value ofAllowsTransparency
property and apply the right WindowChrome: the original if the value isfalse
and one withNonClientFrameEdges="None"
(you can also useGlassFrameThickness = 0
instead) if the value istrue
.NOTE: this solution removes the ability to resize the window using the edges, resizing of the window is done only by the
ResizeGrip
.