我在XYDiagram2D.Series
中有一些LineSeries2D
元素。我想在后面的代码中获得Brush
属性。当我尝试下面的代码时,序列笔刷属性为空。只有在XAML中设置笔刷属性时,我才能得到正确的结果。但是如果我不在XAML中设置它,我希望得到的是Brush
,在默认情况下系列是用来着色的,而不是null。
<dxc:XYDiagram2D.Series>
<dxc:LineSeries2D ArgumentScaleType="Numerical" x:Name="series"
ArgumentDataMember="Time"
ValueDataMember="Value"
DataSource="{Binding Path=ListaChart}">
</dxc:LineSeries2D>
<dxc:LineSeries2D ArgumentScaleType="Numerical" x:Name="series1"
ArgumentDataMember="Time"
ValueDataMember="Value"
DataSource="{Binding Path=ListaChart2}">
</dxc:LineSeries2D>
</dxc:XYDiagram2D.Series>
在后面的代码中:
chart.UpdateData();
chart.UpdateLayout();
foreach (var targetSeries in chart.Diagram.Series.OfType<LineSeries2D>())
{
vm.SelectedChannelBrush = targetSeries.Brush;
}
if (PNUsLB.SelectedIndex == 0)
{
vm.SelectedChannelBrush = series.Brush;
}
else
{
vm.SelectedChannelBrush = series1.Brush;
}
图表的名称是“ChartControl
”。我的问题是,在运行时绘制图表后,series.Brush
、series1.Brush
和targetSeries.Brush
为空。那么如何在后台代码中获得默认的系列颜色呢?
发布于 2013-12-03 20:15:38
我今天也有同样的想法。若要更改画笔的颜色,必须处理从图表控件引发的事件。
使用函数CustomDrawCrosshairEventHandler(chartControl_CustomDrawCrosshair);
public void发送器(object chartControl_CustomDrawCrosshair,DevExpress.Xpf.Charts.CustomDrawCrosshairEventArgs e) { e.CrosshairLineElement.Brush = Brushes.DeepSkyBlue;}
以下是可用于画笔的所有Windows颜色:
祝你好运,Mijat
https://stackoverflow.com/questions/17360014
复制相似问题