这里我的文本框文本被绑定到内容模板中的子文本框,但是如何将默认样式和验证错误与内容模板中的子文本框一起应用。
<TextBox x:Name="tbIdNumber" Width="110" Height="20" Text="{Binding IdNumber, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" >
<TextBox.Template>
<ControlTemplate TargetType="TextBox" >
<StackPanel Orientation="Horizontal" >
<Image Height="10" Width="20" Source="Images/bullet_darkblue.PNG" />
<TextBox Width="90" Tag="{Binding RelativeSource={RelativeSource TemplatedParent}}" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent},Path=DataContext, Mode=TwoWay}"
Text="{Binding Path=Text ,RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" >
</TextBox>
</StackPanel>
</ControlTemplate>
</TextBox.Template>
</TextBox>