本文介绍了覆盖 WPF 工具包图表中的 DataPointStyle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的 WPF 工具包 Chart
中覆盖 LineSeries
的 DataPointStyle
:
I'd like to override the DataPointStyle
of the LineSeries
in my WPF Toolkit Chart
:
<chart:LineSeries>
<chart:DataPointSeries.DataPointStyle>
<Style
BasedOn="{StaticResource {x:Type chart:LineDataPoint}}"
TargetType="{x:Type chart:LineDataPoint}">
<Setter Property="Width" Value="20" />
<Setter Property="Height" Value="20" />
</Style>
</chart:DataPointSeries.DataPointStyle>
</chart:LineSeries>
但是,当我这样做时,我丢失了每个系列具有不同颜色的自动调色板着色.应用 DataPointStyle
会使它们全部变为橙色.
However when I do this I lose the automatic palette coloring where each series has a different color. Applying a DataPointStyle
causes them all to turn orange.
推荐答案
在有人提出更好的方法之前,我已经手动设置了颜色.我想我暂时不会使用自动调色板.
Until someone suggests a better method, I've manually set the colors. I guess I won't be using the automatic palette for now.
<Style
x:Key="SimpleDataPointStyle"
BasedOn="{StaticResource {x:Type charting:LineDataPoint}}"
TargetType="{x:Type charting:LineDataPoint}">
<Setter Property="Width" Value="20" />
<Setter Property="Height" Value="20" />
</Style>
...
<chart:LineSeries ... >
<chart:DataPointSeries.DataPointStyle>
<Style
BasedOn="{StaticResource SimpleDataPointStyle}"
TargetType="{x:Type charting:LineDataPoint}">
<Setter Property="Background" Value="Green" />
</Style>
</chart:DataPointSeries.DataPointStyle>
</chart:LineSeries>
<chart:LineSeries ... >
<chart:DataPointSeries.DataPointStyle>
<Style
BasedOn="{StaticResource SimpleDataPointStyle}"
TargetType="{x:Type charting:LineDataPoint}">
<Setter Property="Background" Value="Red" />
</Style>
</chart:DataPointSeries.DataPointStyle>
</chart:LineSeries>
这篇关于覆盖 WPF 工具包图表中的 DataPointStyle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!