WPF XAML Style syntax

I have some WPF XAML code that I need to merge;

<TextBox Style="{StaticResource textBxErr}" ...>
    <TextBox.Style>
        <Style TargetType="{X:Type TextBox}">
            <Setter Property="IsEnabled" Value="True">
            <Style.Triggers>
                ...
           </Style.Triggers>
       <Style>
    </TextBox.Style>
</TextBox>

Open in new window

I need to move the Style="{StaticResource textBxErr}" down into the <Style TargetType=...> area. Visual Studio isn't happy I'm setting Style in two different places. I just don't know the syntax for how to do that.

Thank you!
deleydAsked:
Who is Participating?
 
louisfrCommented:
If you want to have the textBxErr style with some changes, you need to have a style based on another:
<TextBox>
    <TextBox.Style>
        <Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource textBxErr}">
            <Setter Property="IsEnabled" Value="True">
            <Style.Triggers>
                ...
           </Style.Triggers>
       <Style>
    </TextBox.Style>
</TextBox>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.