MaterialDesignInXamlToolkit
MaterialDesignInXamlToolkit copied to clipboard
WindowChrome affecting drawer animations performance
I've noticed that drawer animations performance drops a lot when the window is maximized while using WindowChrome options with WindowStyle.None
Adding this code to any window and maximizing it should allow to reproduce the issue:
<Window
...
WindowStyle="None"
WindowState="Maximized">
<!-- Important change -->
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="32"/>
</WindowChrome.WindowChrome>
<!-- /Important change -->
<md:DrawerHost IsLeftDrawerOpen="{Binding IsChecked, ElementName=MenuToggle}" Margin="5">
<md:DrawerHost.LeftDrawerContent>
<StackPanel MinWidth="200" DockPanel.Dock="Left" WindowChrome.IsHitTestVisibleInChrome="True">
<ToggleButton Style="{DynamicResource MaterialDesignHamburgerToggleButton}" HorizontalAlignment="Right" Margin="8 4" IsChecked="{Binding IsChecked, ElementName=MenuToggle, Mode=TwoWay}"/>
</StackPanel>
</md:DrawerHost.LeftDrawerContent>
<DockPanel>
<md:ColorZone Padding="8 4" md:ShadowAssist.ShadowDepth="Depth2" Mode="PrimaryMid" DockPanel.Dock="Top" Name="TitleBar">
<DockPanel Height="37">
<ToggleButton Style="{DynamicResource MaterialDesignHamburgerToggleButton}" IsChecked="False" Name="MenuToggle" DockPanel.Dock="Left" WindowChrome.IsHitTestVisibleInChrome="True"/>
</DockPanel>
</md:ColorZone>
<Grid>
</Grid>
</DockPanel>
</md:DrawerHost>
</Window>
It's not only the DrawerHost, which is affected by this. I also recognized this behavior for the DialogHost. Than I also tested some simple animations without MaterialDesign and with WindowChrome. Here I didn't see any difference between WindowState.Normal and WindowState.Maximized.
So my first idea was like yours, that it has only something to do with the DialogHost or DrawerHost implementations.
Than I added ControlsEx.
And now, I don't know if it's an issue, which can be solved here, or if it's a general bug in Microsofts WindowChrome implementation.
Because I could get rid of the performance problem by using the ControlzEx WindowChrome Fork.
Hopefully in future, when all WPF gets OSS, the team around ControlzEx can merge their improvements to the WindowChrome back to Microsofts version.
For quick fix right now I think you can try to install ControlsEx and change your code to something like this:
<Window
...
xmlns:ctrlz="urn:controlzex"
WindowStyle="None"
WindowState="Maximized">
<ctrlz:WindowChrome.WindowChrome>
<ctrlz:WindowChrome CaptionHeight="32"/>
</ctrlz:WindowChrome.WindowChrome>
...
</Window>
And also ctrlz:WindowChrome.IsHitTestVisibleInChrome="True" where needed.
Could it be that the gpu/windows thinks the entire drawer is offscreen?
Also tried that, with a huge border, to be sure that the DrawerHost Control isn't offscreen. But still you get also bad performance.
And the window will still be offscreen with the Microsoft `WindowChrome'.
I have same problem with dialogs. I got only like 5 FPS with this config:
<WindowChrome.WindowChrome>
<WindowChrome
CaptionHeight="45"
CornerRadius="10"
GlassFrameThickness="0,0,0,0"
ResizeBorderThickness="4" />
</WindowChrome.WindowChrome>
Sometimes there is no animation at all :(
Also ControlzEx solution no is longer working