The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
Windows Phone 8.1 apps - Creating button click events RRS feed

  • Question

  • I want to create an image tapped even while creating images in a loop.  But IN the tapped even, i want to know which image sent the tapped event..

    for example:

    for(int x=0; x<5;x++)
    {
    
    Image name+x = new Image();
    
    
    }

    I dont know how to do the rest.

    Thursday, June 5, 2014 5:43 PM

All replies

  • You can get the control which sent the Tap in the sender argument passed to the event.

    I'm not sure what the code snippet you posted is intended to do. Image name+x isn't valid code.

    --Rob

    Thursday, June 5, 2014 6:13 PM
  • You can get the control which sent the Tap in the sender argument passed to the event.

    I'm not sure what the code snippet you posted is intended to do. Image name+x isn't valid code.

    --Rob

            How do i do that?

    Sorry. I meant to delete that. It was suppose to be just

    Image d = new Image();

    Thursday, June 5, 2014 7:53 PM
  •         private void Image_Tapped(object sender, TappedRoutedEventArgs e)
            {
                Image img = sender as Image;
                if (img != null)
                {
                    Debug.WriteLine("We got image named {0} with tag {1}", img.Name, img.Tag);
                }
            }

    Tuesday, June 10, 2014 10:39 PM
  • Hi,

    Incase your images are in a list, you can try out this way-

        private void Listview_ItemClick(object sender, ItemClickEventArgs e)
            {
                var itemId = ((MyListViewItem)e.ClickedItem).UniqueId;
    
                Debug.WriteLine("item id {0}", itemID);
    
            }


    -Malleswar

    Tuesday, June 10, 2014 11:57 PM