Skip to content

950873-Updated .NET Version for Dataform sample #3

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CustomizeCheckBoxColor/CustomizeCheckBoxColor/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ public partial class App : Application
public App()
{
InitializeComponent();

MainPage = new AppShell();
}

protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new MainPage());
}
}
14 changes: 0 additions & 14 deletions CustomizeCheckBoxColor/CustomizeCheckBoxColor/AppShell.xaml

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<!-- Display name -->
<ApplicationTitle>CustomizeCheckBoxColor</ApplicationTitle>
Expand Down Expand Up @@ -49,9 +50,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="*" />
<PackageReference Include="Syncfusion.Maui.Core" Version="*" />
<PackageReference Include="Syncfusion.Maui.DataForm" Version="*" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CustomizeCheckBoxColor"
xmlns:dataForm="clr-namespace:Syncfusion.Maui.DataForm;assembly=Syncfusion.Maui.DataForm"
x:DataType="local:DataFormViewModel"
x:Class="CustomizeCheckBoxColor.MainPage">

<Grid RowDefinitions="0.9*, 1, 60">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ namespace CustomizeCheckBoxColor
{
public class DataFormBehavior : Behavior<ContentPage>
{
private SfDataForm dataForm;
private SfDataForm? dataForm;

private Button applyButton;
private Button? applyButton;

private Button cancelButton;
private Button? cancelButton;
protected override void OnAttachedTo(ContentPage bindable)
{
base.OnAttachedTo(bindable);
Expand Down Expand Up @@ -38,7 +38,7 @@ protected override void OnAttachedTo(ContentPage bindable)
this.applyButton.Clicked += OnApplyButtonClicked;
}
}
private void OnGenerateDataFormItem(object sender, GenerateDataFormItemEventArgs e)
private void OnGenerateDataFormItem(object? sender, GenerateDataFormItemEventArgs e)
{
if (e.DataFormItem!= null)
{
Expand All @@ -48,21 +48,21 @@ private void OnGenerateDataFormItem(object sender, GenerateDataFormItemEventArgs
}
}
}
private async void OnApplyButtonClicked(object sender, EventArgs e)
private async void OnApplyButtonClicked(object? sender, EventArgs e)
{
if (this.dataForm != null && App.Current?.MainPage != null)
if (this.dataForm != null)
{
if (this.dataForm.Validate())
{
await App.Current.MainPage.DisplayAlert("", "Applied successfully", "OK");
await DisplayAlert("", "Applied successfully", "OK");
}
else
{
await App.Current.MainPage.DisplayAlert("", "Please enter the required details", "OK");
await DisplayAlert("", "Please enter the required details", "OK");
}
}
}
private void OnCancelButtonClicked(object sender, EventArgs e)
private void OnCancelButtonClicked(object? sender, EventArgs e)
{
if (this.dataForm != null)

Expand All @@ -88,5 +88,18 @@ protected override void OnDetachingFrom(ContentPage bindable)
this.dataForm.GenerateDataFormItem -= this.OnGenerateDataFormItem;
}
}

/// <summary>
/// Displays an alert dialog to the user.
/// </summary>
/// <param name="title">The title of the alert dialog.</param>
/// <param name="message">The message to display.</param>
/// <param name="cancel">The text for the cancel button.</param>
/// <returns>A task representing the asynchronous alert display operation.</returns>
private Task DisplayAlert(string title, string message, string cancel)
{
return App.Current?.Windows?[0]?.Page!.DisplayAlert(title, message, cancel)
?? Task.FromResult(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public DataFormModel()
this.Address = string.Empty;
this.City = string.Empty;
this.Country = string.Empty;
this.BirthDate = string.Empty;
}

[Display(Prompt = "Enter your name")]
Expand Down