0
我有一个自定义控件从TextBox继承了名为State的dependcy属性。 状态枚举有4个选项{不匹配,等等,好吧,无}绑定到CustomControls问题
的一般是这样的:
<Style TargetType="{x:Type local:CustomTextBox}">
<Style.Triggers>
<Trigger Property="State" Value="Mismatch">
<Setter Property="Background" Value="{StaticResource MismatchBrush}"/>
</Trigger>
</Style.Triggers>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomTextBox}">
<Border Background="{TemplateBinding Background}"
BorederBrush="{TemplateBinding BorederBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
我有类命名迈德特与性能DataState,已发送,收到的每个属性执行INotifyPropertyChanged。
在我的主窗口,我在XAML下面一行:
<custom:CustomTextBox State="{Binding BindingData.DataState}" Text="{Binding BindedData.Sent}"/>
,并在我的视图模型我有一个从类型MyData的字段名为BindedData,当用户发送一些数据BindedData.Sent变化那么如果发生某种逻辑,BindedData状态将更改为“不匹配”,并且customTextBox背景需要处于某种颜色。
问题是背景没有改变它的意思是状态的绑定不工作,而且文本绑定不起作用。
我知道如何在其他情况下绑定工作和我的工作(不与自定义控件),在这里我也检查了调试,我看到一切正常,所以我做错了自定义控件?
在此先感谢!
@Mat现在好吗? – david 2012-01-01 21:13:27