Answered by:
Popup Positioning

Question
-
Hey All,
I am currently having some issues positioning a popup control. I have menu with buttons, on mouse over, i would like a small popup to display with a breif dicription of what the button does or whatever. I dont want it full screen, and i dont want it in aligned on one of the sides. How would i position position the popup near the button or mouse on the mouseover event? Note all the buttons are loaded dynamically.
Any pointers would be great!
Wednesday, May 13, 2009 12:32 PM
Answers
-
Hope this is helpful:
http://silverlight.net/forums/t/95489.aspx
Wednesday, May 13, 2009 12:42 PM -
There are two ways of doing this:
1. Tooltip. You can add a tooltip by utilizing the ToolTipService.Tooltip property
XAML:
<Button ToolTipService.ToolTip="Hello World!" />
2. Mouseover Popup:
C#:
private void PopupOpen(object sender, MouseButtonEventArgs e) { Image visual = sender as Image; GeneralTransform transform = base.TransformToVisual(visual); Point point = transform.Transform(new Point(0.0, 0.0)); PopupWindow.VerticalOffset = this.Margin.Top + Math.Abs(point.Y); PopupWindow.HorizontalOffset = this.Margin.Left + Math.Abs(point.X); PopupWindow.IsOpen = true; }
Wednesday, May 13, 2009 12:50 PM
All replies
-
Hope this is helpful:
http://silverlight.net/forums/t/95489.aspx
Wednesday, May 13, 2009 12:42 PM -
There are two ways of doing this:
1. Tooltip. You can add a tooltip by utilizing the ToolTipService.Tooltip property
XAML:
<Button ToolTipService.ToolTip="Hello World!" />
2. Mouseover Popup:
C#:
private void PopupOpen(object sender, MouseButtonEventArgs e) { Image visual = sender as Image; GeneralTransform transform = base.TransformToVisual(visual); Point point = transform.Transform(new Point(0.0, 0.0)); PopupWindow.VerticalOffset = this.Margin.Top + Math.Abs(point.Y); PopupWindow.HorizontalOffset = this.Margin.Left + Math.Abs(point.X); PopupWindow.IsOpen = true; }
Wednesday, May 13, 2009 12:50 PM -
Hi,
I do believe that this will work, but GeneralTransform transform = base.TransformToVisual(visual); throws a Value does not fall within expected range exception. Any idea?
Thursday, May 14, 2009 2:49 PM -
In my example, I used a popup over an Image. You can change that to the object type that you expect to mouse over.
Thursday, May 14, 2009 3:38 PM