How to open the popup for the RadDropDownButton at the user's mouseclick position?

2 posts, 0 answers
  1. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 30 Jun 2011 Link to this post

    Hello Telerik,

    I'm using a RadDropDownButton as a sort of clickable popup tooltip.  I'd like it if the popup would appear positioned at the user's mouseclick coordinate.

    I thought that was the intent of DropDownPlacement="Absolute" but it seems to set it below the button regardless.  I wondered if it might have been the logic that repositions the popup for screen edge detection, but even if I place the popup in the middle of the screen I still don't get the desired effect.

    Am I doing something incorrectly, or is there a way to move the popup?
  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 06 Jul 2011 Link to this post

    Hello Rob,

    This cannot be achieved with the RadDropDownButton. You said that you try it as a sort of clickable PopupTooltip. So, does creating a custom control (Button + Popup) fit in your scenario? If yes, you could use a RadButton and System.Windows.Controls.Popup that is controlled in the MouseLeftButtonDown event handler like so:
    public MainPage()
               this.button.AddHandler(RadButton.MouseLeftButtonDownEvent, new MouseButtonEventHandler(RadButton_MouseLeftButtonDown), true);
           private void RadButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
               System.Windows.Controls.Primitives.Popup pop= new System.Windows.Controls.Primitives.Popup();
               pop.Width = 300;
               pop.Height = 300;
               pop.Child = new Rectangle() { Width = 200, Height = 200, Fill = new SolidColorBrush() { Color = Colors.Blue }};
               pop.VerticalOffset = e.GetPosition(this.LayoutRoot).Y;
               pop.HorizontalOffset = e.GetPosition(this.LayoutRoot).X;
               pop.IsOpen = true;
    Please let us know if this helped you.

    Petar Mladenov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft R3 2016 release webinar banner
Back to Top