Users Pricing

forum

Home Forums Get the source of image when user clicks it in c# – MindStick

Get the source of image when user clicks it in c#

marcel ethan 2340 14 Aug 2014

I have included four photos in xaml code as follows

                <Image Grid.Column="0"
                       Source="Assets/1.png"
                       Name="m1"
                       MouseLeftButtonDown="selected"/>
                <Image Grid.Column="1"
                       Source="Assets/2.png"
                       Name="m2"
                       MouseLeftButtonDown="selected"/>
                <Image Grid.Column="2"
                       Source="Assets/3.png"
                       Name="m3"
                       MouseLeftButtonDown="selected"/>
                <Image Grid.Column="3"
                       Source="Assets/4.png"
                       Name="m4"
                       MouseLeftButtonDown="selected"/>

I want to get the source of the image in "selected" function. my selected function is as follows

private void selected(object sender, MouseButtonEventArgs e)
    {
        //do somethings....
    }

How can i assign the source of the selected image(sender) to a new Image object?. something similar to follows

Image newimage = new Image();
newimage.Source = //something..

Is there a way to dynamically get the source?


1 Answers

Markdown for AI

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

Open .md