gpt4 book ai didi

windows-runtime - 如何更改 WinRT XAML Toolkit Chart 控件的调色板颜色?

转载 作者:行者123 更新时间:2023-12-01 23:10:50 25 4
gpt4 key购买 nike

如何更改 WinRT XAML Toolkit 图表控件中图表控件的调色板颜色?

例如,我想更改饼图切片的颜色。

最佳答案

如果您在工具包的源代码中搜索“Palette”,您将看到 Chart 控件的默认样式如何具有 Palette 属性,该属性是 ResourceDictionary 的集合>。您可以在您的应用中以类似的方式将其作为图表 Style 或直接作为其属性应用,例如

<charting:Chart
x:Name="PieChartWithCustomPalette"
Title="Pie Chart with Custom Palette"
Margin="70,0">
<charting:Chart.Palette>
<charting:ResourceDictionaryCollection>
<!-- Blue -->
<ResourceDictionary>
<SolidColorBrush
x:Key="Background"
Color="#4586d8" />
<Style
x:Key="DataPointStyle"
TargetType="Control">
<Setter
Property="Background"
Value="{StaticResource Background}" />
</Style>
<Style
x:Key="DataShapeStyle"
TargetType="Shape">
<Setter
Property="Stroke"
Value="{StaticResource Background}" />
<Setter
Property="StrokeThickness"
Value="2" />
<Setter
Property="StrokeMiterLimit"
Value="1" />
<Setter
Property="Fill"
Value="{StaticResource Background}" />
</Style>
</ResourceDictionary>
<!-- Red -->
<ResourceDictionary>
<SolidColorBrush
x:Key="Background"
Color="#dc443f" />
<Style
x:Key="DataPointStyle"
TargetType="Control">
<Setter
Property="Background"
Value="{StaticResource Background}" />
</Style>
<Style
x:Key="DataShapeStyle"
TargetType="Shape">
<Setter
Property="Stroke"
Value="{StaticResource Background}" />
<Setter
Property="StrokeThickness"
Value="2" />
<Setter
Property="StrokeMiterLimit"
Value="1" />
<Setter
Property="Fill"
Value="{StaticResource Background}" />
</Style>
</ResourceDictionary>
</charting:ResourceDictionaryCollection>
</charting:Chart.Palette>
<charting:Chart.Series>
<Series:PieSeries
Title="Population"
ItemsSource="{Binding Items}"
IndependentValueBinding="{Binding Name}"
DependentValueBinding="{Binding Value}"
IsSelectionEnabled="True" />
</charting:Chart.Series>
</charting:Chart>

我将此添加到示例项目中以供将来引用。

enter image description here

关于windows-runtime - 如何更改 WinRT XAML Toolkit Chart 控件的调色板颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14689031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com