Skip to content

Commit bdeeeb7

Browse files
author
EzhilarasanElangovan31
committed
updated view model
1 parent 5340929 commit bdeeeb7

5 files changed

Lines changed: 27 additions & 59 deletions

File tree

Chart_GettingStarted/Chart_GettingStarted/Admission.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

Chart_GettingStarted/Chart_GettingStarted/ChartViewModel.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<ActiveDebugFramework>net8.0-android</ActiveDebugFramework>
4+
<ActiveDebugFramework>net8.0-windows10.0.19041.0</ActiveDebugFramework>
55
<IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
66
<ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
7+
<SelectedPlatformGroup>Emulator</SelectedPlatformGroup>
8+
<DefaultDevice>pixel_5_-_api_34</DefaultDevice>
9+
</PropertyGroup>
10+
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android|AnyCPU'">
11+
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
712
</PropertyGroup>
813
</Project>

Chart_GettingStarted/Chart_GettingStarted/MainPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</chart:SfFunnelChart.Title>
1717

1818
<chart:SfFunnelChart.BindingContext>
19-
<model:ChartViewModel/>
19+
<model:AdmissionViewModel/>
2020
</chart:SfFunnelChart.BindingContext>
2121

2222
<chart:SfFunnelChart.Legend>

README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public partial class MainWindow : ContentPage
2828
{
2929
this.InitializeComponent();
3030
SfFunnelChart chart = new SfFunnelChart();
31+
this.Content = chart;
3132
}
3233
}
3334
```
@@ -72,39 +73,39 @@ Now, let us define a simple data model that represents a data point in the chart
7273

7374
**[C#]**
7475
```
75-
public class Admission
76+
public class AdmissionModel
7677
{
7778
public string XValue { get; set; }
7879
public double YValue { 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 AdmissionViewModel class and initialize a list of `AdmissionModel` objects as follows.
8384

8485
**[C#]**
8586
```
86-
public class ChartViewModel
87+
public class AdmissionViewModel
8788
{
88-
public List<Admission> Data { get; set; }
89+
public List<AdmissionModel> Data { get; set; }
8990
90-
public ChartViewModel()
91+
public AdmissionViewModel()
9192
{
92-
Data = new List<Admission>()
93+
Data = new List<AdmissionModel>()
9394
{
94-
new Admission() {XValue = "Enrolled", YValue=175},
95-
new Admission() {XValue = "Admits", YValue=190},
96-
new Admission() {XValue = "Applicants", YValue=245},
97-
new Admission() {XValue = "Inquiries ", YValue=290},
98-
new Admission() {XValue = "Prospects ", YValue=320},
95+
new AdmissionModel() {XValue = "Enrolled", YValue=175},
96+
new AdmissionModel() {XValue = "Admits", YValue=190},
97+
new AdmissionModel() {XValue = "Applicants", YValue=245},
98+
new AdmissionModel() {XValue = "Inquiries ", YValue=290},
99+
new AdmissionModel() {XValue = "Prospects ", YValue=320},
99100
};
100101
}
101102
}
102103
```
103104

104-
Create a `ViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from `ViewModel` class.
105+
Create a `AdmissionViewModel` instance and set it as the chart's `BindingContext`. This enables property binding from `AdmissionViewModel` class.
105106

106107
> **_Note:_**
107-
Add the namespace of `ViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML.
108+
Add the namespace of `AdmissionViewModel` class to your XAML Page, if you prefer to set `BindingContext` in XAML.
108109

109110
**[XAML]**
110111
```
@@ -115,15 +116,16 @@ Add the namespace of `ViewModel` class to your XAML Page, if you prefer to set `
115116
116117
<chart:SfFunnelChart>
117118
<chart:SfFunnelChart.BindingContext>
118-
<model:ChartViewModel/>
119+
<model:AdmissionViewModel/>
119120
</chart:SfFunnelChart.BindingContext>
120121
</chart:SfFunnelChart>
121122
</ContentPage>
122123
```
123124

124125
**[C#]**
125126
```
126-
ChartViewModel viewModel = new ChartViewModel();
127+
SfFunnelChart chart = new SfFunnelChart();
128+
AdmissionViewModel viewModel = new AdmissionViewModel();
127129
chart.BindingContext = viewModel;
128130
```
129131

@@ -143,7 +145,7 @@ chart.BindingContext = viewModel;
143145
**[C#]**
144146
```
145147
SfFunnelChart chart = new SfFunnelChart();
146-
ChartViewModel viewModel = new ChartViewModel();
148+
AdmissionViewModel viewModel = new AdmissionViewModel();
147149
chart.BindingContext = viewModel;
148150
chart.ItemsSource = viewModel.Data;
149151
chart.XBindingPath = "XValue";
@@ -244,7 +246,7 @@ The following code example gives you the complete code of above configurations.
244246
<Label Text="School Admission"/>
245247
</chart:SfFunnelChart.Title>
246248
<chart:SfFunnelChart.BindingContext>
247-
<model:ChartViewModel/>
249+
<model:AdmissionViewModel/>
248250
</chart:SfFunnelChart.BindingContext>
249251
<chart:SfFunnelChart.Legend>
250252
<chart:ChartLegend/>
@@ -266,7 +268,7 @@ public partial class MainPage : ContentPage
266268
Text = "School Admission"
267269
};
268270
chart.Legend = new ChartLegend();
269-
ChartViewModel viewModel = new ChartViewModel();
271+
AdmissionViewModel viewModel = new AdmissionViewModel();
270272
chart.BindingContext = viewModel;
271273
272274
chart.ItemsSource = viewModel.Data;

0 commit comments

Comments
 (0)