Skip to content

Commit 49b0dfe

Browse files
Merge pull request #3 from SriRadheshNagS/SampleUpdate
950873-Updated .NET Version for Dataform sample
2 parents e7a1954 + 1c9fcc9 commit 49b0dfe

File tree

7 files changed

+37
-37
lines changed

7 files changed

+37
-37
lines changed

CustomizeCheckBoxColor/CustomizeCheckBoxColor/App.xaml.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ public partial class App : Application
55
public App()
66
{
77
InitializeComponent();
8-
9-
MainPage = new AppShell();
108
}
9+
10+
protected override Window CreateWindow(IActivationState? activationState)
11+
{
12+
return new Window(new MainPage());
13+
}
1114
}

CustomizeCheckBoxColor/CustomizeCheckBoxColor/AppShell.xaml

-14
This file was deleted.

CustomizeCheckBoxColor/CustomizeCheckBoxColor/AppShell.xaml.cs

-9
This file was deleted.

CustomizeCheckBoxColor/CustomizeCheckBoxColor/CustomizeCheckBoxColor.csproj

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
5-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
4+
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
5+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>
66
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
77
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
88
<OutputType>Exe</OutputType>
99
<RootNamespace>CustomizeCheckBoxColor</RootNamespace>
1010
<UseMaui>true</UseMaui>
1111
<SingleProject>true</SingleProject>
1212
<ImplicitUsings>enable</ImplicitUsings>
13+
<Nullable>enable</Nullable>
1314

1415
<!-- Display name -->
1516
<ApplicationTitle>CustomizeCheckBoxColor</ApplicationTitle>
@@ -49,9 +50,13 @@
4950
</ItemGroup>
5051

5152
<ItemGroup>
52-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
53+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="*" />
5354
<PackageReference Include="Syncfusion.Maui.Core" Version="*" />
5455
<PackageReference Include="Syncfusion.Maui.DataForm" Version="*" />
5556
</ItemGroup>
5657

58+
<ItemGroup>
59+
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
60+
</ItemGroup>
61+
5762
</Project>

CustomizeCheckBoxColor/CustomizeCheckBoxColor/MainPage.xaml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:local="clr-namespace:CustomizeCheckBoxColor"
55
xmlns:dataForm="clr-namespace:Syncfusion.Maui.DataForm;assembly=Syncfusion.Maui.DataForm"
6+
x:DataType="local:DataFormViewModel"
67
x:Class="CustomizeCheckBoxColor.MainPage">
78

89
<Grid RowDefinitions="0.9*, 1, 60">

CustomizeCheckBoxColor/CustomizeCheckBoxColor/Sample/Behavior/DataFormBehavior.cs

+22-9
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ namespace CustomizeCheckBoxColor
44
{
55
public class DataFormBehavior : Behavior<ContentPage>
66
{
7-
private SfDataForm dataForm;
7+
private SfDataForm? dataForm;
88

9-
private Button applyButton;
9+
private Button? applyButton;
1010

11-
private Button cancelButton;
11+
private Button? cancelButton;
1212
protected override void OnAttachedTo(ContentPage bindable)
1313
{
1414
base.OnAttachedTo(bindable);
@@ -38,7 +38,7 @@ protected override void OnAttachedTo(ContentPage bindable)
3838
this.applyButton.Clicked += OnApplyButtonClicked;
3939
}
4040
}
41-
private void OnGenerateDataFormItem(object sender, GenerateDataFormItemEventArgs e)
41+
private void OnGenerateDataFormItem(object? sender, GenerateDataFormItemEventArgs e)
4242
{
4343
if (e.DataFormItem!= null)
4444
{
@@ -48,21 +48,21 @@ private void OnGenerateDataFormItem(object sender, GenerateDataFormItemEventArgs
4848
}
4949
}
5050
}
51-
private async void OnApplyButtonClicked(object sender, EventArgs e)
51+
private async void OnApplyButtonClicked(object? sender, EventArgs e)
5252
{
53-
if (this.dataForm != null && App.Current?.MainPage != null)
53+
if (this.dataForm != null)
5454
{
5555
if (this.dataForm.Validate())
5656
{
57-
await App.Current.MainPage.DisplayAlert("", "Applied successfully", "OK");
57+
await DisplayAlert("", "Applied successfully", "OK");
5858
}
5959
else
6060
{
61-
await App.Current.MainPage.DisplayAlert("", "Please enter the required details", "OK");
61+
await DisplayAlert("", "Please enter the required details", "OK");
6262
}
6363
}
6464
}
65-
private void OnCancelButtonClicked(object sender, EventArgs e)
65+
private void OnCancelButtonClicked(object? sender, EventArgs e)
6666
{
6767
if (this.dataForm != null)
6868

@@ -88,5 +88,18 @@ protected override void OnDetachingFrom(ContentPage bindable)
8888
this.dataForm.GenerateDataFormItem -= this.OnGenerateDataFormItem;
8989
}
9090
}
91+
92+
/// <summary>
93+
/// Displays an alert dialog to the user.
94+
/// </summary>
95+
/// <param name="title">The title of the alert dialog.</param>
96+
/// <param name="message">The message to display.</param>
97+
/// <param name="cancel">The text for the cancel button.</param>
98+
/// <returns>A task representing the asynchronous alert display operation.</returns>
99+
private Task DisplayAlert(string title, string message, string cancel)
100+
{
101+
return App.Current?.Windows?[0]?.Page!.DisplayAlert(title, message, cancel)
102+
?? Task.FromResult(false);
103+
}
91104
}
92105
}

CustomizeCheckBoxColor/CustomizeCheckBoxColor/Sample/Model/DataFormModel.cs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public DataFormModel()
1111
this.Address = string.Empty;
1212
this.City = string.Empty;
1313
this.Country = string.Empty;
14+
this.BirthDate = string.Empty;
1415
}
1516

1617
[Display(Prompt = "Enter your name")]

0 commit comments

Comments
 (0)