In my WPF I want images on the screen to change, every time when the user clicks right button. The problem is that I have all the time same error message:
'Invalid URI: The format of the URI could not be determined.'
This is the code:
string pic1 = @"C:/Users/Milk/Desktop/exercises/wpf_1/portraits/1.png";
string pic2 = @"C:/Users/Milk/Desktop/exercises/wpf_1/portraits/2.png";
private void buttonRight_Click(object sender, RoutedEventArgs e)
{
List<string> portraits = new List<string>();
portraits.Add(pic1);
portraits.Add(pic2);
string ShowPicture = portraits[counter % portraits.Count];
image.Source = new BitmapImage(new Uri(portraits.ToString()));
counter++;
}
When I tried just with one string, like this:
image.Source = new BitmapImage(new Uri(pic1));
it was working fine, but once it's in the list, it cannot find the file path - at least, that's how this looks like for me.
Any idea how to fix this and where I am making an error?