Users Pricing

forum

Home Forums How to Update/replace image in WFP by clicking button – MindStick

How to Update/replace image in WFP by clicking button

Anonymous User 2517 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>

1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md