Reputation: 13
I have a "ResourceDictionary1.xaml" file to control colors in "MainWindow.xaml" file (intended for skinning) and it is working fine.
To have flexibility over colors, i defined separate SolidColorBrush resource for each individual control. But most of the time multiple SolidColorBrush use same color for clean look.
Now when i want to change the color i need to change it in all SolidColorBrush resources. So i want to bind all the SolidColorBrush color to one Color resource. When i need full control i can just remove the binding and specify another color.
So i created color resource in ResourceDictionary file. But when trying to bind the color the Key does not show up in intelliSense of VisualStudio.
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFWindow.Skins"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Color x:Key="DarkH">#444444</Color>
<Color x:Key="DarkM">#555555</Color>
<Color x:Key="DarkL">#666666</Color>
<sys:String x:Key="TitleName">My App</sys:String>
<sys:Double x:Key="TitleBarHeight">32</sys:Double>
<SolidColorBrush x:Key="CicleMOut" Color="#aaaaaa"/>
<SolidColorBrush x:Key="CicleMOver" Color="#dddddd"/>
<Thickness x:Key="CircleMargin">8</Thickness>
<SolidColorBrush x:Key="TitleBarMOut" Color="#555555"/>
<SolidColorBrush x:Key="TitleBarMOver" Color="#555555"/>
<SolidColorBrush x:Key="ExitMOut" Color="#555555"/>
<SolidColorBrush x:Key="ExitMOver" Color="#666666"/>
<SolidColorBrush x:Key="ExitCross" Color="#aaaaaa"/>
<Thickness x:Key="CrossMargin">12</Thickness>
<sys:Double x:Key="CrossThickness">2</sys:Double>
<SolidColorBrush x:Key="MaxiMOut" Color="#555555"/>
<SolidColorBrush x:Key="MaxiMOver" Color="#666666"/>
<SolidColorBrush x:Key="MaxiBox" Color="#aaaaaa"/>
<Thickness x:Key="BoxMargin">12</Thickness>
<sys:Double x:Key="BoxThickness">1</sys:Double>
<SolidColorBrush x:Key="MiniMOut" Color="#555555"/>
<SolidColorBrush x:Key="MiniMOver" Color="#666666"/>
<SolidColorBrush x:Key="MiniBar" Color="#aaaaaa"/>
<Thickness x:Key="BarMargin">12</Thickness>
<sys:Double x:Key="BarThickness">1</sys:Double>
<SolidColorBrush x:Key="TitleBrs" Color="#aaaaaa"/>
<sys:Double x:Key="TitleFontSize">14</sys:Double>
<SolidColorBrush x:Key="FrmBdy" Color="#666666" />
Say i want to bind SolidColorBrush color to DarkH color.
<SolidColorBrush x:Key="FrmBdy" Color="{Binding DarkH}" />
This doesn't work. I got to know, binding in this way is not possible.
Then is there any other way to make multiple brushes refer to one color?
Because when there are say 20 or more SolidColorBrush, changing colors in each brush to same color doesn't sound efficient and cannot use single SolidColorBrush for above said flexibility reason.
I am new to WPF and migrated from WinForms. Still trying to do some intermediate WPF stuff. Thanks.
Upvotes: 0
Views: 466
Reputation: 4824
You was close
<SolidColorBrush x:Key="FrmBdy" Color="{StaticResource DarkH}" />
Upvotes: 0