Cant capture MouseUp of left button on childen of zoom panel
#4
I do not know why the events for the objects inside ZoomPanel do not fire. I created simple test with PainterSamle and I can get the events fire - see the following code:

Code:
void PainterSample_Loaded(object sender, RoutedEventArgs e)
        {
            // Set the content to be a litte bit smaller than the height of the ZoomPanel
            SetNewContent(null, new Size(ZoomPanel1.ActualHeight * 0.7, ZoomPanel1.ActualHeight - 30));

            Ellipse ellipse = new Ellipse();
            ellipse.Width = 200;
            ellipse.Height = 100;
            ellipse.Fill = Brushes.Red;
            ellipse.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(ellipse_PreviewMouseLeftButtonDown);
            Canvas.SetLeft(ellipse, 50);
            Canvas.SetTop(ellipse, 100);
            PaintCanvas.Children.Add(ellipse);
        }

        void ellipse_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
              // Put breakpoint here
        }

I you would like to put events to ZoomPanel and would like to get the object under the mouse you can use WPF 2D hit testing - see http://rongchaua.net/blog/c-wpf-hit-testing-example/

Another approach would be to put ZoomMode to none. Add the canvas or some other panel as the first child inside ZoomPanel - set its background to some color (can be also Transparent; it it is null than the events will not be fired on the control). Subscribe to mouse left button up and down events on this panel. In the button down you set the ZoomMode to Move and in the button up you set the ZoomMode to None.

Now you can add controls to the panel and subscribe to the events on them and do whatever you want in those event handlers.

This way you would get your events when you click on the controls inside the panel. But if you would click on the root panel (the empty space around your controls) you would start panning.
Andrej Benedik
  


Messages In This Thread
RE: Cant capture MouseUp of left button on childen of zoom panel - by abenedik - 11-11-2011, 09:57 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)