I have a class that is a viewmodel (using Prism). It has an associated XAML view. When I do
this.Cursor
there isn't any Cursor property available. What must I do in order to access the cursor so I can change its icon?
Since the Cursor
is a UI-related property, you should set the cursor in the View, not the ViewModel. this.Cursor
should work fine from the code-behind the View
If your Cursor
is based on something in the ViewModel
such as if it's loading data, then use a DataTrigger
in your XAML to change the Cursor when something like an IsLoading
property is set to true
<Style TargetType="{x:Type Window}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsLoading}" Value="True">
<Setter Property="Cursor" Value="Wait" />
</DataTrigger>
</Style.Triggers>
</Style>