Tooltip / Popup content gets created immediately rather than on popup
I have a tooltip containing some custom XAML.
This tooltip is applied to many objects on my display, and the content is not cheap to produce. I naively assumed that the content creation would get deferred until the toolip was actually shown, but this is not the case. Every single popup and its content gets created when the view is created!
I have custom popups with a similar problem. Is there any way to tell WPF to de开发者_StackOverflow社区fer construction in XAML, or do I have to derive my own tooltip / popup class to do it?
Cheers.
You could apply styles programmatically. Of course that will allow you to defer execution to any event you want.
http://en.csharp-online.net/WPF_Styles_and_Control_Templates%E2%80%94Setting_Styles_Programmatically
Note: controls can't have multiple styles in WPF, which could complicate your problem depending on how stylish your controls are.
精彩评论