Monday, 12 August 2013

Windows 8 Metro app, How to set a click event for different images that are loaded?

Windows 8 Metro app, How to set a click event for different images that
are loaded?

I've created a drag and drop function in my app which i've used a code
sample and works ok. The images need to have a click event, so ive used
the tapped event. However I need the event to have a different result.
So basically, the xaml code for the image source is as so.
Image Source="{Binding Image}" Tapped="chordClicked"
and in the C#
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;
}
I tried a few variations on how I could go about doing this but none have
worked, I thought the method below would make sense.
for the time being the text block is just a way of testing if the click is
working properly
private void chordClicked(object sender, TappedRoutedEventArgs e)
{
if (source = ("Assets/Achord.png"))
{
textBlock.Text = "A chord clicked";
}
Thank you in advance

No comments:

Post a Comment