0
Reply

Load Images as Buttons/add Click event to Image

Matthew Brooking

Matthew Brooking

Aug 5 2013 10:21 AM
1.2k
Hi there,

Im developing an app for Windows 8 store in Visual Studio 2012 using C# and XAML.

The page I'm currently working on has a drag and drop feature, the drag and drop works more or less fine however, I need the images to have a click event however I am unsure of how to go about it.

I want to be able to either:
a)Load the images as a button add the click event this way.
b)or being able to add a click event to the image (of which i've tried and i'm either doing it wrong or can't be done).


this is the code loading the images from the assets folder in my project.

protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            source.Add(new Item("Assets/Achord.png"));
            source.Add(new Item("Assets/Bchord.png"));
            source.Add(new Item("Assets/Cchord.png"));
            source.Add(new Item("Assets/Dchord.png"));
            source.Add(new Item("Assets/Echord.png"));
            source.Add(new Item("Assets/Fchord.png"));
            source.Add(new Item("Assets/Gchord.png"));
            
            availableItems.ItemsSource = source;
            chosenItems.ItemsSource = destination;
         }

Thanks in advance