tags:

views:

80

answers:

1

Still a bit new to the concept of M-V-VM in WPF, here's my problem:

I've built up my ui pretty cleanly, I have the following:

  • CareersView.xaml - View
  • CareersView.xaml.cs - View (Code Behind)
  • CareersViewModel.cs - View-Model
  • Career - Model

The View-Model is all wired up through bindings and cleanly keeps all logic inside it for testability.

What I need to do now is set the entire view's cursor property. However in the context of the ViewModel, it does not know about the view. How would I go about this under the MVVM paradigm. I don't want to resort to code-behind where possible.

+3  A: 

You can use a DataTrigger for this. Just have the DataTrigger bound to a property on the ViewModel, and when it's set to a specific value, change the View's Cursor property as needed.

This has the advantage of allowing your ViewModel to be completely unaware of "cursors" - it just sets a property (such as IsBusy), and the cursor logic is 100% View.

Reed Copsey
Thanks Reed, this is exactly what I was looking for!
Aren