I have a polygon which has a MouseLeftButtonDown event. When I click near its edges (say 10 pixes inside from the borders) the event is not called. What could be the problem of this?
Secondly, can we add child of a polygon?
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Polygon p = new Polygon() {
Stroke = Brushes.Black,
StrokeThickness = 2,
Points = new PointCollection() {new Point(10,10), new Point(50,10),
new Point(56, 45) }};
p.MouseLeftButtonDown += new MouseButtonEventHandler(p_MouseLeftButtonDown);
mygrd.Children.Add(p);
}
void p_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Entered");
}
give the polygon a fill brush and your mouse event fires