The following control definition works ok:
<local:TextBoxEx Text="{Binding Title, UpdateSourceTrigger=PropertyChanged, Delay=900}"
Foreground="{Binding Selection.Error, Converter={StaticResource BoolToErrorBrush}}"/>
When I change it using a style:
<Style x:Key="TextBoxTitle" TargetType="local:TextBoxEx">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<local:TextBoxEx Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
Foreground="Blue"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<local:TextBoxEx Text="{Binding Title, UpdateSourceTrigger=PropertyChanged, Delay=900}"
Style="{StaticResource TextBoxTitle}"
Foreground="Pink"/>
The binding to Title overrules the style binding to Text and works.
Setting the Foreground color has no effect, it is still blue.
When I use Foreground="{TemplateBinding Foreground}"
in the controltemplate style it works.
I cannot understand this behaviour, can you?
In the first case the local definition is leading, in the second case it is not.