0

I'm new to WPF and follow the code explained in

How to position tooltip bottom center

to center a tooltip. However, I received the message "The resource CenterToolTipConverter could not be resolved." I think I should be including the class "CenterToolTipConverter" in the wrong place. How or where should I include "CenterToolTipConverter" class?

Thanks!

P.S.: Sorry my poor English.

Community
  • 1
  • 1
user3952846
  • 143
  • 4
  • 13
  • 1
    Don't show us *their* code.... there's no problem with their code... show us *your* code. Did you actually create a `CenterToolTipConverter` class in your project? – Sheridan Aug 18 '14 at 13:52
  • I created that Class and put it inside the WpfApplication1 namespace, after the "public partial class MainWindow : Window". I thought that new classes added there would be immediately accessible. – user3952846 Aug 18 '14 at 14:40
  • Wow! If you don't even know enough to add a class to your project, then you really need to go back to the books (if you ever even looked at them in the first place). This website is not here so that we can all give up our time to help completely new users to learn a language when they haven't even spent any time learning themselves. We're here to help developers that help themselves... *you* need to go off and do the learning yourself *first*. Even if we told you what to do, you probably wouldn't understand it, so what's the point? – Sheridan Aug 18 '14 at 14:55
  • Sheridan, I'm developing themes to wpf and even still newbie in WPF, I already created several style classes that worked correctly, even with triggers and animation. This is the first case that I needed, effectively, a class in C # for positioning an element. That's why I asked for help, I do not think it is so difficult to give some basic tips in this case. – user3952846 Aug 18 '14 at 16:42
  • You should learn to walk before you can fly. Have you tried looking at the [`IMultiValueConverter` Interface](http://msdn.microsoft.com/en-us/library/system.windows.data.imultivalueconverter(v=vs.110).aspx) page? – Sheridan Aug 18 '14 at 21:41
  • I agree with you. But sometimes we learn to fly faster, trying and falling and rising again. That's the way the birds do. Anyway, thanks for your help. – user3952846 Aug 19 '14 at 10:20

1 Answers1

0

Normally ou put Converter and stuff in the Resources Section:

for example if it's a UserControl

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

Then from the post you mentioned:

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

what you are probably missing is the xmlns-entry:

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

where yournamespace is the namespace of the Class CenterToolTipConverter

Helpful Links:

XAML Namespaces and Namespace Mapping for WPF XAML

XAML Resources

Mark
  • 3,273
  • 2
  • 36
  • 54