Setting Mouse Cursor in WinformsHost

424 views Asked by At

I am working on a WPF application that has a WinformsHost element. I try to set the cursor for the winforms host element, but this does not have any effect. I tried to use the ForceCursor property of the window, but this seems to be ignored completely.

In my sample window I have a WPF Textblock on the left with a Hand cursor which is used properly, but on the right side where I have a WinForms PropertyGrid, I get the same behavior.

<Window x:Class="WpfWinformsCursor.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
        Title="MainWindow" Height="350" Width="525"
        Cursor="ScrollAll"
        ForceCursor="False"
        >
    <Grid Cursor="Pen">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid Grid.Column="0" Cursor="Help">
            <TextBlock Cursor="Hand" />
        </Grid>
        <WindowsFormsHost Grid.Column="1" Cursor="ScrollNW">
            <wf:PropertyGrid Cursor="Hand" />
        </WindowsFormsHost>
    </Grid>
</Window>

Can somebody help me how to do this correctly?

0

There are 0 answers