我在Windows手机应用中创建了一个图表。这是我的代码XAML
<amq:SerialChart x:Name="line" DataSource="{Binding results}" CategoryValueMemberPath="month"
AxisForeground="White"
PlotAreaBackground="Black"
GridStroke="DarkGray" >
<amq:SerialChart.Graphs>
<amq:LineGraph Title="Sales" ValueMemberPath="actual" Brush="red" StrokeThickness="5" />
</amq:SerialChart.Graphs>
</amq:SerialChart>
如何使用c#(仅限代码)
编写此XAML答案 0 :(得分:1)
如何使用c#(仅限代码)
编写此XAML
一般来说,这通常不是一个好主意。但如果你必须,你会使用这些方面的东西:
var chart = new SerialChart
{
CategoryValueMemberPath = "month",
AxisForeground = new SolidColorBrush(Colors.White),
PlotAreaBackground = new SolidColorBrush(Colors.Black),
GridStroke = new SolidColorBrush(Colors.DarkGray)
};
chart.SetBinding(SerialChart.DataSourceProperty, new Binding("results"));
var lineGraph = new LineGraph
{
Title = "Sales",
ValueMemberPath = "actual",
Brush = new SolidColorBrush(Colors.Red),
StrokeThickness = "5"
};
chart.Graphs.Add(lineGraph);
然后您只需要使用例如stackPanel.Children.Add(chart)
将图表添加到页面/容器中。
答案 1 :(得分:0)
var chart = new SerialChart
{
CategoryValueMemberPath = "month",
AxisForeground = new SolidColorBrush(Colors.White),
PlotAreaBackground = new SolidColorBrush(Colors.Black),
GridStroke = new SolidColorBrush(Colors.DarkGray)
};
chart.SetValue(SerialChart.DataSourceProperty, new Binding("results"));
var lineGraph = new LineGraph
{
Title = "Sales",
ValueMemberPath = "actual",
Brush = new SolidColorBrush(Colors.Red),
StrokeThickness = 5
};
chart.Graphs.Add(lineGraph);