Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello.
I want change background for all user controls in my wpf application.I add following code to Generic.xaml and App.xaml but dont work!!!

XML
<Style TargetType="{x:Type UserControl}">
        <Setter Property="Background" Value="LightBlue"/>
    </Style>


can anybody help me on this please?????????
Thanks in advance
Regards
Posted
Comments
saman.h 2-Sep-14 15:19pm    
Thanks for solutions but i have more than 20 user Control in my project and don't want set background for all manually.
I insert above code in ResourceDictionary file(Generic.xaml).
can anybody help me on this please?????????
Thanks in advance

Kindly check the below link

http://stackoverflow.com/questions/632356/wpf-usercontrol-style[^]

Hope it helps
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-Sep-14 13:42pm    
This answer touches only one specific bug or misconception of the inquirer (which OP maybe not even going to make), without any attempts to cover the topic. May I ask you: did you just do a Wen search and picked first link which seemed relevant to you? Instead of trying to help OP?
—SA
Here is how:
http://msdn.microsoft.com/en-us/library/ms745683%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/bb384338%28v=vs.110%29.aspx[^].

Also, if you have more than one window in the application and want to share the styles between windows, you would need to put the styles in external ResourceDictionary (separate XML file) and use this dictionary in all windows' XAML:
http://msdn.microsoft.com/en-us/library/cc903952%28v=vs.95%29.aspx[^],
http://msdn.microsoft.com/en-Us/library/windows/apps/windows.ui.xaml.resourcedictionary.aspx[^],
http://msdn.microsoft.com/en-us/library/system.windows.resourcedictionary.mergeddictionaries%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
v2

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