WPF - dynamic hint

I have a class ToolTipProvider that has a method

string GetToolTip(UIElement element)

which will return a specific hint for the specified UIElement based on various factors, including the properties of the UIElement itself, as well as a search in the documentation, which can be changed dynamically. It will also probably work in the stream, so when the form first launches the tooltips, there will be something like a visual studio called “Document cache is still building” and then filled in the background.

I want this to be possible to use in any form of wpf with minimal effort for the developer. Essentially, I want to insert a resource ObjectDataProviderin Window.Resourcesto wrap my object ToolTipProvider, then I think I need to create a tooltip (called, for example MyToolTipProvider) in resources that refers to ObjectDataProvider, and then any item that requires this tooltip function , it will be just a case ToolTip="{StaticResource MyToolTipProvider}" however I cannot work: a) how to associate the actual element with the MethodParameters of the dataprovider object, or b) how to make it call the method every time the tooltip opens.

Any ideas / pointers to the general outline I need? Do not look for a complete solution, just ideas from more experienced

+3
2
  • , factory.

  • , , factory, (, , ..)

<AnyControl>
    <AnyControl.ToolTip>
        <YourToolTipControl Content="{Binding}" />
    </AnyControl.ToolTip>
</AnyControl>
+1

, , , ​​ . , , , , , . , , , .

0

Source: https://habr.com/ru/post/1707756/


All Articles