I want to show all the ToolTips on a view as soon as it's opened. That's fine, I can set the ToolTip.IsOpen properties to true. That certainly shows the ToolTips, the problem is they all show up at (0, 0). Apparently the positioning of the ToolTips doesn't happen until its target control is hovered. Only after hovering are the ToolTips positioned correctly. Setting focus to all the controls first doesn't help either; the target control has to receive the hover event. I'm assuming the ToolTip hooks into the hover event of its target and positions itself inside this event. Is there a protected method I can call in a ToolTip subclass or some such?
ToolTipService.SetPlacement(button1,
System.Windows.Controls.Primitives.PlacementMode.Top);
See this MSDN Page to see all the placement options
EDIT
See this article about the custom positioning of tooltips. It refers to a project on codeplex that contains the code: SmartToolTips
As far as I can tell what I'm asking here is not possible beyond manually doing layout or customizing the source. I implemented a completely custom tooltip instead. sigh
Related
I am working on a simple text editor that allows the user to hover over words in the text and get information about them. I am looking for a way to control a tooltip that pops up based on my own logic the drives from the MouseMove event. Trying to create a simple popup that acts similar to a code editing window when you are debugging and looking at variable symbol values by hovering the mouse over words in the text.
I am not seeing an obvious way to force the tooltip to show/hide on-demand.
Instead of using the ToolTip property, you could use a Popup element and set its IsOpen property to control when you want to display it.
You can style it to look like a ToolTip.
I'm using a UI-Grid control for user input in a big project at work. There are cases when the grids should be available in read-only mode, meaning that any clicks from the user should remain without effect.
I have searched the documentation as much as I could, but all I've come up with is the isRowSelectable property in the options of the grid. However, I am also using the grid as a treeView. And the expand/collapse buttons are still active.
Is there a possibility to make the grid read-only as if it had supported a "disabled" attribute the way that text inputs do? Is it possible to disable it altogether?
In the end, I have used a div acting as an overlay that I put right above the grid. It has a semi-transparent gray background, the exact dimensions of the grid, a higher z-index, a not-allowed cursor, and a no-op click handler.
Depending on whether the parent container of the grid (and the overlay) has a CSS class that says the grid is meant to be disabled, the overlay shows up and blocks the user from interacting with the grid. It's a simple solution that covers my needs.
I am customizing the tooltip on my user control so that it looks like a callout. The tooltip is set to appear above the control (Placement=Top) with an arrow pointing down toward it.
The problem is when the control is near the edge of the screen, the tooltip is not aligned to the left-side of the control. As a result, the arrow points to an empty space to the left of the control.
Even worse, if the control is near the top of the screen, the tooltip shows up below the target control and the arrow pointing down.
Any idea how to resolve this? I am looking for some way to programmatically create the tooltip on the fly or set a trigger to select the Style based on some properties in the tooltip but I don't know how.
I have faced the same problem in the past and what I did was get the position of the PlacementTarget via PointToScreen(new Point(0,0)) and get the position of the ToolTip by calling the same method and then doing the math to figure out whether the ToolTip is correctly positioned or not. If it wasn't, then I changed the Placement of the ToolTip according to whether it was showing up to the left, right, above or below the PlacementTarget. Also, keep in mind, that PointToScreen() will only work once the ToolTip has rendered so attach a handler to ToolTip.Open and do it in there. Hope this helped. Let me know if you come across a more efficient/better way to solve this problem.
I have created a custom popup to decorate my buttons with animated tooltips. I track Button.MouseEnter for the button to decide when to display the popup. I use Button.MouseLeave to determine when to hide the popup.
Problem is Button.MouseLeave is fired prematurely if the popup moves over the mouse cursor (its appearance is animated) despite the fact that I have set IsHitTestVisible = false for the popup and all its visual children.
Is this the way WPF is designed to work? I need MouseLeave to only fire when the cursor moves away from the button itself and not be influenced by the popup.
Thanks
I believe that the Popup control is actually contained within a window, which is why the popup can extend beyond the window bounds in some cases. (It's also why popup transparency is not supported in Silverlight.)
I believe that while the popup control is no longer processing "hits", the container window is, which is why you are losing your button's mouse focus.
I've not tested this, but you might try creating a template for your button and actually declaring the popup as part of the button (rather than below it). This may cause WPF to view the popup control as part of the button and eliminate the problem of losing mouse focus. This works in other scenarios, but I'm not 100% sure how this will work with a Popup.
EDIT: As a side note, the deault WPF tooltip allows you to override the template. I'm not sure what your goals are, but you may find it easier to change the appearance and behavior of the default tooltip than to try to roll your own, as a lot of these sorts of problems have already been solved in the default Tooltip.
I am using a third party charting library (Infragistics xamChart). I am not satisfied with how tooltips are displayed on a line charts datapoints so I was thinking of using an adorner to make a better looking/interactive tooltip.
What I want to do is have the adorner popup whenever one of the datapoints is hovered over. Does anyone have any pointers on how I can do this? Most of the adorner samples I found are pretty simple ones that just alter the entire control they are adorning.
My main questions are:
Is it possible for an adorner to
appear only when certain elements are
hovered over (and have it appear at
the current cursor position)?
Does anyone have a simple sample they
can share?
Are adorners the right way to go
here? I think the only other option
was to use the popup control but I
though adorners were a nicer
solution.
Thank you.
Perhaps Attached Behaviours could help you? From this article:
The idea is that you set an attached
property on an element so that you can
gain access to the element from the
class that exposes the attached
property. Once that class has access
to the element, it can hook events on
it.
That way you could attach a listener to the MouseEnter event and display your custom ToolTip from there.