forum

home / developersection / forums / how to update/replace image in wfp by clicking button

How to Update/replace image in WFP by clicking button

Anonymous User 2327 21-Sep-2013

So I have an image that when the user clicks on a button it will change it to a new item. However, whenever the user clicks on one of the button, the window will go blank. How can I get this to work? Thank you.

private void Next_Click(object sender, RoutedEventArgs e)
{
    if (imageNumber > 6)
    {
        imageNumber = 1;
    }
    imageNumber++;
    string sUri = string.Format("@/Resources/{0}", imageSource[imageNumber]);
    Uri src = new Uri(sUri, UriKind.Relative);
    var bmp = new BitmapImage(src);
    img.Source = bmp;           
}

Xaml Code:-

<Image x:Name="img">
    <Image.Source>
        <BitmapImage UriSource="Resources/BlackJackTut-1.jpg" />
    </Image.Source>
</Image>

wpf wpf 
Updated on 21-Sep-2013

I am a content writter !


Message
Can you answer this question?

Answer

1 Answers

Liked By