Home Ask Login Register

Developers Planet

Your answer is one click away!

Jeffrey Haines February 2016

How do you style a single TextBox among others?

I have a WPF textbox among others that I would like to create a style for.

This style should only apply to this type of textbox.

Here is my textbox:

<TextBox Text="{Binding DeviceInformation.SerialNumber, Mode=OneWay}"  BorderThickness="0" Background="Transparent" IsReadOnly="True"/>

My text box basically simulates a label I can copy.

How do I make this into a style and target only this textbox?


Filip February 2016

If you set Key property on your Style definition, then it will be applied only on TextBoxes that have set this Style. Style={StaticResource=ExampleKey}


        <Style TargetType="TextBox" x:Key="ExampleStyle">
            <Setter Property="BorderThickness" Value="0"></Setter>

You can also have application-wide styles defined in App.xaml

Post Status

Asked in February 2016
Viewed 2,469 times
Voted 14
Answered 1 times


Leave an answer

Quote of the day: live life