Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

I am working with one WPF application. I have created style as follows,

XML
<Window.Resources>
        <Style x:Key="ST" TargetType="TextBox">
            <Setter Property="Width" Value="40"></Setter>
        </Style>
    </Window.Resources>


I wanted to apply this style to all TextBox in my current window without going to each control and set its style.

Thanks
Posted

1 solution

Try to omit the x:Key attribute of the Style.

 
Share this answer
 
Comments
[no name] 25-Mar-12 7:42am    
Hey it works. Thanks.5!
[no name] 25-Mar-12 7:45am    
Can you plz suggest way, if I want to add this style for all the element of a grid (or stack panel)
Shmuel Zang 25-Mar-12 7:56am    
Just put the Style in the resources of the Grid or the StackPanel (instead of in the resources of the Window).
[no name] 25-Mar-12 9:36am    
Worked! Thx.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900