Version

Custom Cursors

Before You Begin

You can override the default cursors that are used when your end users resize the xamDialogWindow control. This can be achieved by setting the CustomCursors object’s DiagonalResizeCursor, HorizontalResizeCursor and VerticalResizeCursor properties.

Assumptions

This topic assumes that you already have a xamDialogWindow control on your page. For more information, see the Adding xamDialogWindow to Your Page topic.

What You Will Accomplish

You will customize the resizing cursors by setting the CustomCursors object’s DiagonalResizeCursor, HorizontalResizeCursor, VerticalResizeCursor properties to custom templates.

Follow these Steps

  1. Create a resource dictionary on your page.

In XAML:

<UserControl.Resources>
   <!-- TODO: Add DataTemplate -->
</UserControl.Resources>
  1. Create a DataTemplate. Set the x:Name property to HorizontalResizeCustomCursor.

In XAML:

<DataTemplate x:Key="HorizontalResizeCustomCursor">
   <!-- TODO: Add Grid Panel -->
</DataTemplate>
  1. Add a Grid panel to the DataTemplate. Set the following properties:

    • Height - 20

    • Width - 20

In XAML:

<Grid Height="20" Width="20"
   <!-- TODO: Add Button -->
</Grid>
  1. Add an Image to the Grid panel. Set the following properties:

    • Stretch - Fill

    • Source - /Images/HorizontalResizeCursor

In XAML:

<Image Stretch="Fill"
       Source="/Images/HorizontalResizeCursor.png">
</Image>
  1. Create a DataTemplate. Set the x:Name property to VerticalResizeCustomCursor.

In XAML:

<DataTemplate x:Key="VerticalResizeCustomCursor">
   <!-- TODO: Add Grid Panel -->
</DataTemplate>
  1. Add a Grid panel to the DataTemplate. Set the following properties:

    • Height - 20

    • Width - 20

In XAML:

<Grid Height="20" Width="20">
   <!-- TODO: Add Image -->
</Grid>
  1. Add an Image to the Grid panel. Set the following properties:

    • Stretch - Fill

    • Source - /Images/VerticalResizeCursor

In XAML:

<Image Stretch="Fill"
       Source="/Images/VerticalResizeCursor.png">
</Image>
  1. Create a DataTemplate. Set the x:Name property to DiagonalResizeCustomCursor.

In XAML:

<DataTemplate x:Key="DiagonalResizeCustomCursor">
   <!-- TODO: Add Grid Panel -->
</DataTemplate>
  1. Add a Grid panel to the DataTemplate. Set the following properties:

    • Height - 20

    • Width - 20

In XAML:

<Grid Height="20" Width="20">
   <!-- TODO: Add Image -->
</Grid>
  1. Add an Image to the Grid panel. Set the following properties:

    • Stretch - Fill

    • Source - /Images/DiagonalResizeCursor

In XAML:

<Image Stretch="Fill"
       Source="/Images/DiagonalResizeCursor.png">
</Image>
  1. Set the following CustomCursors object’s properties:

    • DiagonalResizeCursor – {StaticResource DiagonalResizeCustomCursor}

    • HorizontalResizeCursor – {StaticResource HorizontalResizeCustomCursor}

    • VerticalResizeCursor – {StaticResource VerticalResizeCustomCursor}

In XAML:

<Grid x:Name="LayoutRoot" Background="White">
   <ig:XamDialogWindow x:Name="DialogWindow" Width="200"
       Height="200" IsModal="True"        Content="This is a sample dialog">
      <ig:XamDialogWindow.CustomCursors>
         <ig:CustomCursors
             DiagonalResizeCursor="{StaticResource DiagonalResizeCustomCursor}"
             HorizontalResizeCursor="{StaticResource HorizontalResizeCustomCursor}"
             VerticalResizeCursor="{StaticResource VerticalResizeCustomCursor}" />
      </ig:XamDialogWindow.CustomCursors>
   </ig:XamDialogWindow>
</Grid>
  1. Save and run your application.

Custom Cursors