forum

Home / DeveloperSection / Forums / Get the source of image when user clicks it in c#

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

marcel ethan 1781 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?


c# c# 
Updated on 14-Aug-2014

Can you answer this question?


Answer

1 Answers

Liked By