views:

48

answers:

2

Why this works

<myToolTip:UserControl1>
   <TextBlock Text="{Binding Path=TestString, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type myToolTip:UserControl1}}}"/>
</myToolTip:UserControl1>

BUT this does not

<myToolTip:UserControl1 x:Name="userControl">
   <TextBlock Text="{Binding Path=TestString, ElementName=userControl}"/>
</myToolTip:UserControl1>

and is there really no shorter (faster) way, to access usercontrols elements?! Sincerely, 0xDEAD BEEF

+1  A: 

This is possibly the known issue described in this post: http://blogs.visoftinc.com/archive/2009/11/19/Silverlight-3-ElementName-DataBinding-Problem.aspx

It refers to Silverlight, but appears to be an issue with the XAML parser, not SL or WPF.

The good news is that it works as expected in the next version, though I'm sure that doesn't help much now.

Jay
+1  A: 

Here's an explanation and work-around.

Travis Heseman