G
G
Gennady2018-03-03 18:34:11
.NET
Gennady, 2018-03-03 18:34:11

How to change image on WPF form?

Good afternoon, comrades!
I have an image on a WPF form

<Image x:Name="MainImage" Source="C:\temp\test.jpg"  HorizontalAlignment="Left" Height="300" Width="450" VerticalAlignment="Top" />

Tell me how to change the Source so that the picture changes on the form?
Got the following method:
Uri uri = new Uri(@"C:\temp\IMG_0690.JPG", UriKind.Relative);
            ImageSource imgSource = new BitmapImage(uri);

            MainImage.Source = imgSource;

But despite the absence of errors during compilation and during execution, the picture does not change.
Perhaps some additional action is required?
Thank you in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gennady, 2018-03-03
@genana40

Got this option
Works) Question removed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question