0

Hopefully the question makes sense. What I would like to do is place an Ellipse (or styled button to look like an Ellipse with an icon inside in a user control that is dynamically populated in my code behind, and then be able to determine when the Ellipse was tapped on the user control and perform a separate action than when the user control is tapped. The sample I'm using actually comes from a Nokia Imaging SDK sample with a few tweaks.

PhotoThumbnail.xaml //The UserControl

    <Ellipse Grid.Row="0" Grid.Column="1" Stroke="LightGray" StrokeThickness="3"
             VerticalAlignment="Top" HorizontalAlignment="Right" Width="50" Height="50" Margin="7"/>

PhotoThumbnail.xaml.cs

    public event PropertyChangedEventHandler PropertyChanged;

    public PhotoThumbnail()
    {
        InitializeComponent();

        DataContext = this;
    }

Page.xaml.cs

//Creae PhotoThumbnail
                    PhotoThumbnail photoThumbnail = new PhotoThumbnail()
                    {
                              ..                 
                    };

                    photoThumbnail.Tap += (object sender, System.Windows.Input.GestureEventArgs e) =>
                    {
                        // do something
                    };

                    panel.Children.Add(photoThumbnail);
                }
            }
        }
    }

The photoThumbnail.Tap event above performs an action, but how can I determine if the user tapped the Ellipse on the PhotoThumbnail UserControl as opposed to the control itself?

David Božjak
  • 16,887
  • 18
  • 67
  • 98
Matthew
  • 3,976
  • 15
  • 66
  • 130

1 Answers1

0

I just added the following in Page.xaml.cs and named the Ellipse in the User Control x:Name="EditableEllipse"

photoThumbnail.EditableEllipse.Tap += (object sender, System.Windows.Input.GestureEventArgs e) =>
                    {
                        if (sender != null)
                        {
                            .. do something ..
                        }
                    };
Matthew
  • 3,976
  • 15
  • 66
  • 130