I am trying to get a custom cursor for my WPF application. I already have the .cur file in the Resources. In the xaml, I mentioned the resource dictionary something like this:
<Window.Resources>
<ResourceDictionary>
<FrameworkElement x:Key="KinectCursor" Cursor="Resources/KinectCursor.cur"/>
<FrameworkElement x:Key="KinectCursor16" Cursor="Resources/KinectCursor16.cur"/>
</ResourceDictionary>
</Window.Resources>
In the code-behind, I tried to the set the Mouse.OverrdeCursor property to this cursor but it is throwing exceptions.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
//Mouse.OverrideCursor = this.Resources["KinectCursor"].Cursor;
Mouse.OverrideCursor = ((FrameworkElement)this.Resources["KinectCursor"]).Cursor;
//DisplayArea.Cursor = Cursors.Hand;
}
Exception Message:
XAMLParseException occured.
'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension'
threw an exception.' Line number '7' and line position '14'.