行为中的DataContext继承

时间:2011-09-19 08:49:52

标签: c# wpf xaml

我在DependencyProperties后面的代码中声明了3 MainWindow。以下代码段位于MainWindow

的xaml代码中
<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>

这些绑定不起作用。我认为这是因为行为不会从父控件继承DataContext。我知道当我使用Freezable时,DataContext是继承的,但它不起作用。

  

System.Windows.Data错误:2:找不到目标元素的管理FrameworkElement或FrameworkContentElement。 BindingExpression:路径= BOOL1;的的DataItem =空; target元素是'Matcher'(HashCode = 59587750); target属性为'Value1'(类型'Boolean')

为什么DataContext没有继承?

0 个答案:

没有答案
相关问题