我有放了幾個顏色在ResourceDictionary中 如:
I use ResourceDictionary to pack some color settings,like
<ResourceDictionary x:Name="The_Resources">
<!--Global Styles-->
<Color x:Key="color_A">#2196F3</Color>
<Color x:Key="color_B">Khaki</Color>
<Color x:Key="color_C">Coral</Color>
<Style x:Key="Button_Style" TargetType="Button" x:Name="Button_Style">
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="BackgroundColor" Value="{StaticResource color_B}" />
<Setter Property="FontSize" Value="Default" />
</Style>
</ResourceDictionary >
C#可以用這樣的方式讀取ResourceDictionary的Style:
C# can get the Style in ResourceDictionary just like:
Button 按鈕 = new Button
{
//BackgroundColor = Color.LightSteelBlue,
Style = App.Current.Resources["Button_Style"] as Style,
};
但要怎麼在C#中取得Colo_A B C的顏色賦予BackgroundColor呢?
but can C# read Color_A B C to set BackgroundColor?