How do I set the DataContext of "myElement" to the same DataContext as the user control in XAML? I have been able to do it in code-behind via myElement.DataContext = this.DataContext
in the UserControl constructor, but I'm trying to understand how to do the same thing in XAML.
This is related to creating virtual branches to the logical tree (see this article).
<UserControl ... DataContext="{Binding RelativeSource={RelativeSource self}}">
...
<TextBox Name="myTextBox">
<TextBox.Text>
<Binding Path="MySource" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<base:StringEqualsRules>
<base:StringEqualRule.BoundElement>
<base:ValidationRuleElement
x:Name="myElement"
DataContext="???"
Value="{Binding MyProperty}" />
</base:StringEqualRule.BoundElement>
</base:StringEqualsRule>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
...
</UserControl>