WPF databind Image.Source in MVVM

Posted by BrettRobi on Stack Overflow See other posts from Stack Overflow or by BrettRobi
Published on 2010-03-28T01:03:14Z Indexed on 2010/03/28 1:13 UTC
Read the original article Hit count: 1163

Filed under:
|
|

I'm using MVVM and am trying to databind the Source property of Image to my ViewModel in such a way that I can change the icon on the fly. What is the best pattern to follow for this? I still have the flexibility to change my ViewModel to suit, but I don't know where to start in either the xaml or ViewModel.

To be clear, I don't want my ViewModel to know about the specific images (that's for the View to know), just the state that triggers different images. For now I have just two states, lets say Red and Green. Should I create an Enum property or a bool? And then how do I databind to switch the image source?

© Stack Overflow or respective owner

Related posts about wpf

Related posts about databinding