【问题标题】:Binding to properties of a control in a tooltip在工具提示中绑定到控件的属性
【发布时间】:2009-05-20 01:32:43
【问题描述】:

我想在其工具提示中显示(自定义)标签的一些属性, 但我似乎无法让它正常工作,所以一定是做错了什么:

<Label.ToolTip>
    <Border BorderBrush="Gray" CornerRadius="5" Margin="5" Padding="5">
       <Label Content="{Binding Path=Width, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Label}}}"/>  
    </Border>
</Label.ToolTip>

有什么想法吗?

【问题讨论】:

  • Visual Studio 中的输出是否表明出了什么问题?
  • 是的,它找不到我正在寻找的标签实例。但正如你所见,我已经找到了解决方案:-)

标签: .net wpf data-binding xaml


【解决方案1】:

我找到了解决办法

<ToolTip  DataContext="{Binding Path=PlacementTarget, RelativeSource={x:Static RelativeSource.Self}}">

感谢卡尔!

http://karlshifflett.wordpress.com/2007/12/29/wpf-sample-series-data-binding-in-tooltip/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-03-19
    • 1970-01-01
    • 1970-01-01
    • 2011-03-07
    • 1970-01-01
    • 2018-02-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多