WPF - Dynamic tooltip

Posted by Al Mackenzie on Stack Overflow See other posts from Stack Overflow or by Al Mackenzie
Published on 2009-05-06T11:46:43Z Indexed on 2010/04/16 23:03 UTC
Read the original article Hit count: 662

Filed under:
|
|

I have a class ToolTipProvider which has a method

string GetToolTip(UIElement element)

which will return a specific tooltip for the UIElement specified, based on various factors including properties of the UIElement itself and also looking up into documentation which can be changed dynamically. It will also probably run in a thread so when the form first fires up the tooltips will be something like the visual studio 'Document cache is still being constructed', then populated in the background.

I want to allow this to be used in any wpf form with the minimum effort for the developer. Essentially I want to insert an ObjectDataProvider resource into the Window.Resources to wrap my ToolTipProvider object, then I think I need to create a tooltip (called e.g. MyToolTipProvider) in the resources which references that ObjectDataProvider, then on any element which requires this tooltip functionality it would just be a case of ToolTip="{StaticResource MyToolTipProvider}" however I can't work out a) how to bind the actual elemnt itself to the MethodParameters of the objectdataprovider, or b) how to force it to call the method each time the tooltip is opened.

Any ideas/pointers on the general pattern I need? Not looking for complete solution, just any ideas from those more experienced

© Stack Overflow or respective owner

Related posts about wpf

Related posts about c#