Hi Simon Earnshaw,
Firstly all the image you want to dynamically switch from user control should be with that property
1. Build Action : Resource
2. Copy to output directory : Do not copy.
And following is the sample code to switch
Let say in xaml
<Image x:Name="ImgStatus" Grid.Column="1" Grid.Row="0" Width="32" Height="32" Source="pack://application:,,,/[your name space];component/[folder name if you put your image into the folder]/[your image name].png" VerticalAlignment="Top"></Image>
In cs file
private void SetStatus()
{
this.ImgStatus.Source = this.BuildImage([Your desire image name]);
}
private ImageSource BuildImage(string imageName)
{
return new BitmapImage(PackUriForResource(imageName));
}
private Uri PackUriForResource(string resourceName)
{
string asm = System.IO.Path.GetFileNameWithoutExtension(
System.Reflection.Assembly.GetExecutingAssembly().CodeBase);
return new Uri(string.Format("pack://application:,,,/{0};component/[Your image folder path]/{1}", asm, resourceName), UriKind.Absolute);
}
Make sure you replace those variable with [] properly from the sample code. and try it.
If you used mvvm, data context, you shall need to use ImageSource data type to bind and use BuildImage method to change the image with image name.
Hope it will help you.
Let me know the status.