WPF以工具提示为中心

时间:2014-08-18 13:45:45

标签: wpf tooltip

我是WPF的新手并遵循

中解释的代码

How to position tooltip bottom center

以工具提示为中心。但是,我收到消息“无法解析资源CenterToolTipConverter”。我想我应该把类“CenterToolTipConverter”包含在错误的地方。我应该如何或在哪里包含“CenterToolTipConverter”类?

谢谢!

P.S。:对不起,我的英语很差。

1 个答案:

答案 0 :(得分:0)

通常你把Converter和东西放在参考资料部分:

例如,如果它是UserControl

<UserControl.Resources>
    <converter:CenterToolTipConverter x:Key="centerTooltipConverter" />
</UserControl.Resources>

然后从你提到的帖子开始:

<MultiBinding Converter="{StaticResource centerTooltipConverter}">
    <Binding RelativeSource="{RelativeSource Self}" Path="PlacementTarget.ActualWidth"/>
    <Binding RelativeSource="{RelativeSource Self}" Path="ActualWidth"/>
</MultiBinding>

你可能缺少的是xmlns-entry:

xmlns:converter="clr-namespace:yournamespace;assembly=yourassembly"

其中yournamespace是类CenterToolTipConverter

的命名空间

有用的链接:

XAML Namespaces and Namespace Mapping for WPF XAML

XAML Resources

相关问题