In this step, we will bind the chart to a data source.
XAML |
Copy Code
|
---|---|
DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}" |
XAML |
Copy Code
|
---|---|
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="-81,0,-361,-56"> <Grid.RowDefinitions> <RowDefinition Height="93*"/> <RowDefinition Height="97*"/> </Grid.RowDefinitions> <Chart:C1FlexChart x:Name="flexChart" HorizontalAlignment="Left" Width="443" ItemsSource="{Binding DataContext.Data}" BindingX="Fruit" Margin="198,18,0,235" Grid.RowSpan="2"> <Chart:C1FlexChart.Series> <Chart:Series SeriesName="March" Binding="March"></Chart:Series> <Chart:Series SeriesName="April" Binding="April"></Chart:Series> <Chart:Series SeriesName="May" Binding="May"></Chart:Series> </Chart:C1FlexChart.Series> <Chart:C1FlexChart.AxisX> <Chart:Axis MajorGrid="False" Position="Bottom"></Chart:Axis> </Chart:C1FlexChart.AxisX> <Chart:C1FlexChart.AxisY> <Chart:Axis AxisLine="False" Position="Left" MajorUnit="5"></Chart:Axis> </Chart:C1FlexChart.AxisY> <Chart:C1FlexChart.SelectionStyle> <Chart:ChartStyle Stroke="Red"></Chart:ChartStyle> </Chart:C1FlexChart.SelectionStyle> </Chart:C1FlexChart> </Grid> |