I am trying to change a image in the UI running with WPF on runtime by changing the source of the image. Unfortunately the image is not changing. I found examples of using a Bitmap image to change the Image source, but with ReactiveUI I am not able to change the UriSource for the BitmapImage.
XAML code:
<Image x:Name="button_image0" DockPanel.Dock="Top" Source="someimage.jpg" Stretch="Uniform" />
view code:
this.OneWayBind(ViewModel, vm => vm.button_image0, v => v.button_image0).DisposeWith(d);
Viewmodel code:
[Reactive] public string button_image0 { get; set; }
//button pressed
button_image0 = "newimage.jpg";
I checked that the source of the image is changing, but the image displayed is not. Does someone know how to solve this with reactiveUI or knows a way around?
Solution If anyone is having the same problem, it's a syntax error of your code. When changing the source of an image using reactiveUI the image is reloaded. This question and answer confused me Reloading an image in wpf