You can use a DataTrigger and change the image (completely in XAML) based on the value of the property in the ViewModel. I personally used the listing, as you may need several states.
VisualStateManager will also work for this, but it will require WPF Futures or .NET 4.
To use a DataTrigger, you can do something like:
<Image> <Image.Style> <Style TargetType="Image"> <Setter Property="Source" Value="1.png" /> <Style.Triggers> <DataTrigger Binding="{Binding ViewModelEnumProperty}" Value="Image2"> <Setter Property="Source" Value="2.png" /> </DataTrigger> </Style.Triggers> </Style> </Image.Style> </Image>
This will use "1.png", but when your listing is set to "Image2" in the virtual machine, it will switch to 2.png. If necessary, add more DataTriggers.
Reed copsey
source share