@@ -28,6 +28,7 @@ public partial class MainWindow : ContentPage
2828 {
2929 this.InitializeComponent();
3030 SfPyramidChart chart = new SfPyramidChart();
31+ this.Content = chart;
3132 }
3233}
3334```
@@ -72,38 +73,38 @@ Now, let us define a simple data model that represents a data point in the chart
7273
7374** [ C#] **
7475```
75- public class Stage
76+ public class StageModel
7677{
7778 public string Name { get; set; }
7879 public double Value { get; set; }
7980}
8081```
8182
82- Next, create a view model class and initialize a list of ` Model ` objects as follows.
83+ Next, create a StageViewModel class and initialize a list of ` StageModel ` objects as follows.
8384
8485** [ C#] **
8586```
86- public class ChartViewModel
87+ public class StageViewModel
8788{
88- public List<Stage > Data { get; set; }
89+ public List<StageModel > Data { get; set; }
8990
90- public ChartViewModel ()
91+ public StageViewModel ()
9192 {
92- Data = new List<Stage >()
93+ Data = new List<StageModel >()
9394 {
94- new Stage (){Name = "Stage A", Value = 12},
95- new Stage (){Name = "Stage B", Value = 21},
96- new Stage (){Name = "Stage C", Value = 29},
97- new Stage (){Name = "Stage D", Value = 37},
95+ new StageModel (){Name = "Stage A", Value = 12},
96+ new StageModel (){Name = "Stage B", Value = 21},
97+ new StageModel (){Name = "Stage C", Value = 29},
98+ new StageModel (){Name = "Stage D", Value = 37},
9899 };
99100 }
100101}
101102```
102103
103- Create a ` ViewModel ` instance and set it as the chart's ` BindingContext ` . This enables property binding from ` ViewModel ` class.
104+ Create a ` StageViewModel ` instance and set it as the chart's ` BindingContext ` . This enables property binding from ` StageViewModel ` class.
104105
105106> ** _ Note:_ **
106- Add the namespace of ` ViewModel ` class to your XAML Page, if you prefer to set ` BindingContext ` in XAML.
107+ Add the namespace of ` StageViewModel ` class to your XAML Page, if you prefer to set ` BindingContext ` in XAML.
107108
108109** [ XAML] **
109110```
@@ -114,16 +115,18 @@ Add the namespace of `ViewModel` class to your XAML Page, if you prefer to set `
114115
115116 <chart:SfPyramidChart>
116117 <chart:SfPyramidChart.BindingContext>
117- <model:ChartViewModel />
118+ <model:StageViewModel />
118119 </chart:SfPyramidChart.BindingContext>
119120 </chart:SfPyramidChart>
120121</ContentPage>
121122```
122123
123124** [ C#] **
124125```
125- ChartViewModel viewModel = new ChartViewModel();
126+ SfPyramidChart chart = new SfPyramidChart();
127+ StageViewModel viewModel = new StageViewModel();
126128chart.BindingContext = viewModel;
129+ this.Content = chart;
127130```
128131
129132## Populate chart with data
@@ -142,7 +145,7 @@ chart.BindingContext = viewModel;
142145** [ C#] **
143146```
144147SfPyramidChart chart = new SfPyramidChart();
145- ChartViewModel viewModel = new ChartViewModel ();
148+ StageViewModel viewModel = new StageViewModel ();
146149chart.BindingContext = viewModel;
147150chart.ItemsSource = viewModel.Data;
148151chart.XBindingPath = "Name";
@@ -243,7 +246,7 @@ The following code example gives you the complete code of above configurations.
243246 <Label Text="Pyramid Stages"/>
244247 </chart:SfPyramidChart.Title>
245248 <chart:SfPyramidChart.BindingContext>
246- <model:ChartViewModel />
249+ <model:StageViewModel />
247250 </chart:SfPyramidChart.BindingContext>
248251 <chart:SfPyramidChart.Legend>
249252 <chart:ChartLegend/>
@@ -265,7 +268,7 @@ public partial class MainPage : ContentPage
265268 Text = "Pyramid Stages"
266269 };
267270 chart.Legend = new ChartLegend();
268- ChartViewModel viewModel = new ChartViewModel ();
271+ StageViewModel viewModel = new StageViewModel ();
269272 chart.BindingContext = viewModel;
270273
271274 chart.ItemsSource = viewModel.Data;
0 commit comments