我想SolidColorBrush
在应用程序运行时从 c# 代码更改 xaml 中的颜色。(这是来自 WinRT XAML Toolkit 的饼图,我想更改切片的颜色。)
<charting:Chart.Palette>
<charting:ResourceDictionaryCollection>
<ResourceDictionary>
<SolidColorBrush x:Key="MyBrush" Color="#4586d8"/>
<Style x:Key="DataPointStyle" TargetType="Control">
<Setter Property="Background" Value="{StaticResource MyBrush}"/>
</Style>
</ResourceDictionary>
</charting:ResourceDictionaryCollection>
</charting:Chart.Palette>
由于 Win8 应用程序中没有 DynamicResource,这就是我尝试设置但没有成功的方式:
Color yellow = Color.FromArgb(0xff, 0xff, 0xb9, 0x01);
Application.Current.Resources["MyBrush"] = new SolidColorBrush(yellow);
如何设置资源的颜色?