Setting the cursor in a WPF documentViewer

825 Views Asked by At

I am creating a WPF document viewer that will zoom in to a page when it is double clicked on. To this end I am trying to get the cursor to turn into a hand when over a page in the document viewer, and an arrow when elsewhere.

I have my xaml set up like so

<UserControl x:Class="WPFXPSViewerControl.XPSControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:UI="clr-namespace:Bluewire.Epro.UI;assembly=EproClientCore"
         xmlns:System="clr-namespace:System;assembly=mscorlib" mc:Ignorable="d"
         Loaded="Window_Loaded"
         Height="1200" MouseDoubleClick="Double_Click">
<Grid Grid.Row="2" Grid.Column="2" Cursor="Hand">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="20" Cursor="Arrow"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition />
        <ColumnDefinition />
    </Grid.ColumnDefinitions>

    <DocumentViewer Name="document" Grid.ColumnSpan="2" Cursor="Arrow">

    </DocumentViewer>
    <Button Width="200" Name="btnZoomIn" Grid.Row="1" Grid.Column="0" Cursor="Hand" Click="btnZoomIn_Click">Zoom In</Button>
    <Button Width="200" Name="btnZoomOut" Grid.Row="1" Grid.Column="1" Cursor="Hand" Click="btnZoomOut_Click">Zoom Out</Button>
</Grid>

</UserControl>

However, I cannot seem to change the cursor when it is over a page from its default setting of a text cursor.

1

There are 1 best solutions below

0
On

You could try the following statements:

Cursor="Arrow"  ForceCursor="True"