工具提示/弹出内容立即创建,而不是在弹出窗口上创建
我有一个包含一些自定义 XAML 的工具提示。
此工具提示适用于我显示器上的许多对象,并且内容的制作成本并不便宜。我天真地认为内容创建会推迟到实际显示工具栏时,但事实并非如此。每个弹出窗口及其内容都是在创建视图时创建的!
我的自定义弹出窗口也有类似的问题。有没有办法告诉 WPF 在 XAML 中推迟构造,或者我是否必须派生自己的工具提示/弹出类来执行此操作?
干杯。
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 defer construction in XAML, or do I have to derive my own tooltip / popup class to do it?
Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过编程方式应用样式。当然,这将允许您将执行推迟到您想要的任何事件。
http://en.csharp-online.net/WPF_Styles_and_Control_Templates%E2%80%94Setting_Styles_Programmatically
注意:WPF 中控件不能有多种样式,这可能会使您的问题变得复杂,具体取决于您的控件的时尚程度。
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.