DataContext Inheritance in Behavior
I have 3 DependencyProperties
declared in code behind of the MainWindow
. The following code snippet is in the xaml code of the MainWindow
:
<TextBlock>
<e:Interaction.Behaviors>
<bhv:VisibilityBehaviour>
<mat:Matcher Value1="{Binding BOOL1}"/>
<mat:Matcher Value1="{Binding BOOL2}"/>
<mat:Matcher Value1="{Binding BOOL3}"/>
</bhv:VisibilityBehaviour>
</e:Interaction.Behaviors>
</TextBlock>
These Binding don't work. I think it's because the Behavior doesn't inherit the DataContext
from parent Control. I know that when I use Freezable the DataContex开发者_如何学Ct
is inherited but it doesn't work.
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=BOOL1; DataItem=null; target element is 'Matcher' (HashCode=59587750); target property is 'Value1' (type 'Boolean')
Why isn't the DataContext inherited?
精彩评论