Prevent RadMap from receiving handled double click event

5 posts, 0 answers
  1. Etienne
    Etienne avatar
    47 posts
    Member since:
    Sep 2014

    Posted 24 Aug 2015 Link to this post

    Hi,

    Is it possible to not receive handled MouseDoubleClickEvent and MapMouseDoubleClickEvent in RadMap when the event is handled in a item of a map layer ? I've joined a sample that demonstrates the problematic behavior (for me).

    Thank you,

    Etienne

  2. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 27 Aug 2015 Link to this post

    Hi Etienne,

    Since of the complex template structure of the map the handling MouseDoubleClick of the Pushpin won't affect the MouseDoubleClick event of the map as you may expect. In order to achieve your requirement you can use a bool flag in the event handlers. Here is an example in code:
    private bool isMapDoubleClickHandled = false;
    private void pushpin_MouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
        var pushpin = sender as Pushpin;
        if (pushpin != null)
        {      
            this.isMapDoubleClickHandled = true;
            MessageBox.Show("pushpin_MouseDoubleClick");
        }
    }
     
    private void RadMap_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
        if (!this.isMapDoubleClickHandled)
        {  
            MessageBox.Show("RadMap_OnMouseDoubleClick");
        }
        else
        {
            this.isMapDoubleClickHandled = false;
        }
    }

    Please give this approach a try and let me know if it works for you.

    Regards,
    Martin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Etienne
    Etienne avatar
    47 posts
    Member since:
    Sep 2014

    Posted 28 Aug 2015 in reply to Martin Link to this post

    Hi Martin,

    Thanks for your solution, it works great but I would have hope something more clean. Is it planned to improve RadMap so that double click event behave as expected ? That would be nice.

    Thank you,

    Etienne

  5. Martin
    Admin
    Martin avatar
    1099 posts

    Posted 01 Sep 2015 Link to this post

    Hello Etienne,

    Actually, this behavior is expected in the WPF framework and we can't consider it as an unexpected behavior in the map. Handling the MouseDoubleClick event of a child element won't prevent the parent's MouseDoubleClick from firing. You can check this with nested ContentControl (or ItemsControl) elements. In order to prevent an element's event to bubble to its parent you can use the preview event. So, for your case you can try the following approach:
    void radMap_InitializeCompleted(object sender, EventArgs e)
    {
        if (!_initialized)
        {
            _initialized = true;
             
            // add pushpin
            var pushpin = new Pushpin();
            MapLayer.SetLocation(pushpin, new Location(40, -100));
            pushpin.PreviewMouseDoubleClick += pushpin_PreviewMouseDoubleClick; 
     
            informationLayer.Items.Add(pushpin);
        }
    }
    .
    void pushpin_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
    {
        var pushpin = sender as Pushpin;
        if (pushpin != null)
        {
            e.Handled = true
            MessageBox.Show("pushpin_MouseDoubleClick");
        }
    }

    Regards,
    Martin
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Etienne
    Etienne avatar
    47 posts
    Member since:
    Sep 2014

    Posted 01 Sep 2015 in reply to Martin Link to this post

    Hi Martin,

    Thanks for your reply, you're right. I had not realized that MouseDoubleClick is a direct event and not a bubble event. I'll try your approach.

    Regards,

    Etienne

Back to Top
UI for WPF is Visual Studio 2017 Ready