Reputation: 2104
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?
Upvotes: 2
Views: 259
Reputation: 57919
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.
Upvotes: 1