我有以下文本框,在我添加样式之前,绑定工作得很好:
<TextBox Text="{Binding SelectedGroupPolicyTermSummary.ImportantInfo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
HorizontalAlignment="Stretch" AcceptsReturn="True"
IsReadOnly="{Binding IsEditable, Converter={StaticResource InvertedBoolConverter}}"
Foreground="Red" TextWrapping="Wrap">
<TextBox.Style>
<Style TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="TextBox.IsReadOnly" Value="True">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<TextBox Text="{TemplateBinding Text}"
VerticalAlignment="Bottom"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
Style="{DynamicResource SelectableTextStyle}"
TextWrapping="{TemplateBinding TextWrapping}"
Foreground="{TemplateBinding Foreground}"
Width="{TemplateBinding Width}"/>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Width" Value="Auto"/>
</Trigger>
<Trigger Property="TextBox.IsReadOnly" Value="False">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}" >
<TextBox Text="{TemplateBinding Text}"
VerticalAlignment="Bottom"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
Style="{DynamicResource TextBoxStyle}"
TextWrapping="{TemplateBinding TextWrapping}"
Foreground="{TemplateBinding Foreground}"
Width="{TemplateBinding Width}"
AcceptsReturn="{TemplateBinding AcceptsReturn}">
</TextBox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
在我应用样式后,文本框会填充,但任何更改都不会发送回代码。任何想法为什么?