Changing the cursor in the resizing handle in a WPF window ("CanResizeWithGrip" + "WindowStyle: none")

None of the other StackOverflow questions seem to answer this particular question. Or it could be lousy search skills ...

I have an application (" CanResizeWithGrip " + " WindowStyle="none" ") written in WPF / C# .
The application changes only to the side ( MaxHeight and MinHeight ), so I would like the ResizeGrip cursor ResizeGrip be ScrollWE (horizontal only) instead of the default diagonal value. Users try to resize vertically when the cursor tells them what they can.

I tried changing the control template using the code below, but then the whole window disappears and I only remain with the resizegrip user interface and still the diagonal cursor!

 <Window.Template> <ControlTemplate TargetType="Window"> <ResizeGrip Cursor="ScrollWE" /> </ControlTemplate> </Window.Template> 

Resizing works correctly, the window is styled correctly (when I do not use the ControlTemplate above).
I only need to change the cursor that appears above the ResizeGrip . How to do it?

Tips for directions to follow are also welcome (full answers even more :)).


Edit: Hans is right to comment. I mistakenly used ScollSE in my trial version of ControlTemplate (I fixed this in the question now).

+4
source share
1 answer

If I create a window with the following markup

 <Window x:Class="PocketExample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <DockPanel> <ResizeGrip DockPanel.Dock="Bottom" Cursor="SizeWE"/> </DockPanel> </Window> 

I get the correct cursor. This does not work for you? Are you really using a ScrollSE cursor? As Hans points out, this is a diagonal cursor that explains why you get a diagonal pointer.

+3
source

All Articles