Update 26/09/2011 - There's an updated version available in the archive 'Zuker.WpfSamples.zip' with minor bug fixes.
Finally, the last post of the series :)
Initial posts -
WPF Popups and ToolTip behavior - A Journey
WPF Popups and ToolTip Behavior – Implementation
Attached is my final solution with a working example.
Usage
<Control>
<controls:RichToolTip.PopupContent>
<RichToolTip>
<TextBlock Text="This will be displayed in the popup" />
</RichToolTip>
</controls:RichToolTip.PopupContent>
</Control>
Dependency Properties: (Popup Placement Related)
- Placement
- PlacementTarget
- PlacementRectangle
- HorizontalOffset
- VerticalOffset
Properties
- EnableAnimation – Applies cool opening effect. (defaults to true)
- RelatedObject – the object the popup content was assigned to. Handy in some cases. (Check the example project)
Commands
- CloseCommand – Closes the opened tooltip. (You can place buttons in the RichToolTip content / contenttemplate which will invoke it in order to close it)
Attached Properties:
- PopupContent – The main entry point for using the RichToolTip (See usage section). you can provide any object which will be made the the tooltip content. (For being able to set placement or other properties you should insert the RichToolTip itself – see attached code)
- HideOnClick – A helper property for allowing a button which triggers some command to close the opened tooltip as well. I needed it – seemed useful :)
Known Issues
- The popup hides itself when repositioning is needed (window is moved, resize, etc..). This is the common popup behavior (Tooltip and ContextMenu themselves) so I consider this as an overall logical behavior.
- In XBAP mode -
- Transparency is set through a hack and is only supported in Full Trust mode.
- Moving the mouse real slowly towards the popup will cause it to hide (If it bothers you, you could modify the code and use a timer)
- Hovering the mouse over the associated element shows the RichToolTip even though the browser window isn’t the active window.
CodeProject
Published
Sunday, January 18, 2009 5:38 PM
by
Amir Zuker