What you want is something like this:
// This is your view model or .xaml.cs if your Window is acting as its own
// DataContext
private ImageSource _imgSource = null;
public ImageSource IconImageSource {
get {
if (_imgSource == null) {
var url = "";
//check current theme
if (FrameworkApplication.ApplicationTheme ==
ApplicationTheme.Default) {
//light theme icon
//note: full path looks something like this:
//@"pack://application:,,,/MyCustomApp;component/MyImages/WindowIcon.png";
url = "/MyImages/WindowIcon.png";
}
else {
//dark theme icon
url = "/MyImages/WindowIconDark.png";
}
var bmp = new BitmapImage();
bmp.BeginInit();
bmp.UriSource = new Uri(url, UriKind.RelativeOrAbsolute);
bmp.EndInit();
_imgSource = bmp;
}
return _imgSource;
}
}
//In your .xaml
<Image Source={Binding IconImageSource} .... />
In your addin, add two images - one for your "light" and one for your "dark". Make sure to set the BuildAction to "Resource". You may have to fiddle with the pack Uri. In my example, there would be two images in the addin stored in a folder called "MyImages".
Notice I am _binding_ the image source to a property as opposed to setting it to a DynamicResource.