【问题标题】:How I can get all colors in OxyPlot?如何在 OxyPlot 中获得所有颜色?
【发布时间】:2018-11-09 03:50:29
【问题描述】:

我有一个问题。我在 WPF、C# 中使用 OxyPlot。我需要为系列提供 MarkerType 和 MarkerStroke 的所有颜色。我怎样才能得到所有颜色?

【问题讨论】:

  • 把你的代码放在你试过的地方..
  • 公开列表 koloryWykresow=new List { OxyPlot.OxyColors.Green, OxyPlot.OxyColors.IndianRed, OxyPlot.OxyColors.Coral, OxyPlot.OxyColors.Chartreuse, OxyPlot.OxyColors.Peru };我必须改变这个代码列表只有一些元素。我可以写很多颜色,但这不是聪明的解决方案
  • @Mario,您能对我的回答提供任何反馈吗?

标签: c# wpf oxyplot


【解决方案1】:

Green、IndianRed 等是静态 OxyColors 类中的静态字段。使用 阅读所有内容

var colors = typeof(OxyColors)
             .GetFields(BindingFlags.Static | BindingFlags.Public)
             .Where(f => f.FieldType == typeof(OxyColor))
             .Select(f => f.GetValue(null))
             .Cast<OxyColor>()
             .ToList();

【讨论】:

  • 有一个类似的问题我测试了它,它工作正常。 However I am wondering if there is a more elegant solution to this(当我们已经将所有信息保存在 OxyColors 类中时,我不喜欢创建另一个所有颜色列表的想法。)
  • OxyColors 不包含列表。但是您可以创建自己的并将其存储在任何相关类的static 属性中
猜你喜欢
  • 1970-01-01
  • 2014-08-30
  • 2011-08-04
  • 2015-09-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多