【问题标题】:WPF Tooltip, is there some sort of OnHintWPF 工具提示,是否有某种 OnHint
【发布时间】:2014-04-14 13:41:20
【问题描述】:

我有一个在某种桌面上显示一些 ContentControls 的应用程序。

现在我想在这些控件上显示工具提示。 但是工具提示会不时发生变化,并且工具提示的文本来自应用程序外部。所以我需要一些类似于提示出现时的回调,而不是要求外部部分显示文本。

如何做到这一点?

【问题讨论】:

    标签: wpf


    【解决方案1】:

    如果您为工具提示使用数据绑定,则可以从绑定属性中获取新的外部数据,并且每次显示工具提示时都会更新该数据。 XAML 看起来像这样:

    <ContentControl ToolTip="{Binding MyExternalDataProperty}"/>
    

    对于这样设置的 DataContext 对象:

    public class DataContextForControl
    {
      public string MyExternalDataProperty
      {
        get { return MyOutsideDataReader.SomeData; }
      }
    }
    

    【讨论】:

    • 这太容易了!谢谢。
    猜你喜欢
    • 1970-01-01
    • 2011-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-03
    • 1970-01-01
    相关资源
    最近更新 更多