Skip to content

Commit f32bcc5

Browse files
Merge pull request #2 from SriRadheshNagS/UpdateSample
950873-Updated .NET Version for Dataform sample
2 parents d91a558 + 034d3c5 commit f32bcc5

File tree

5 files changed

+32
-64
lines changed

5 files changed

+32
-64
lines changed

CustomEditor/App.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ public partial class App : Application
55
public App()
66
{
77
InitializeComponent();
8+
}
89

9-
MainPage = new AppShell();
10+
protected override Window CreateWindow(IActivationState? activationState)
11+
{
12+
return new Window(new MainPage());
1013
}
1114
}
1215
}

CustomEditor/CustomDataEditor.cs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,55 @@
11
using Syncfusion.Maui.DataForm;
22
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
73

84
namespace CustomEditor
95
{
106
internal class CustomDataEditor : IDataFormEditor
117
{
128
private SfDataForm dataForm;
13-
private DataFormCustomItem dataFormCustomItem;
9+
private DataFormCustomItem? dataFormCustomItem;
1410

1511
public CustomDataEditor(SfDataForm dataForm)
1612
{
1713
this.dataForm = dataForm;
1814
}
15+
1916
public void CommitValue(DataFormItem dataFormItem, View view)
2017
{
21-
dataFormItem.SetValue((view as Entry).Text);
18+
dataFormItem.SetValue((view as Entry)?.Text);
2219
}
2320

2421
public View CreateEditorView(DataFormItem dataFormItem)
2522
{
26-
dataFormCustomItem = (DataFormCustomItem)dataFormItem;
27-
if(dataFormItem.FieldName=="ProfileImage")
23+
dataFormCustomItem = dataFormItem as DataFormCustomItem;
24+
25+
if (dataFormItem.FieldName == "ProfileImage")
2826
{
2927
var view = new Image()
3028
{
31-
Source=(dataFormItem.BindingContext as DataFormViewModel).ContactFormModel.ProfileImage,
32-
HorizontalOptions=LayoutOptions.Center,
33-
HeightRequest=80,
34-
WidthRequest=80
29+
Source = (dataFormItem.BindingContext as DataFormViewModel)?.ContactFormModel.ProfileImage,
30+
HorizontalOptions = LayoutOptions.Center,
31+
HeightRequest = 80,
32+
WidthRequest = 80
3533
};
36-
3734
return view;
3835
}
39-
else if(dataFormItem.FieldName=="Name")
36+
else if (dataFormItem.FieldName == "Name")
4037
{
4138
var entry = new Entry()
4239
{
43-
HorizontalOptions=LayoutOptions.Start,
44-
VerticalOptions=LayoutOptions.Center
40+
HorizontalOptions = LayoutOptions.Start,
41+
VerticalOptions = LayoutOptions.Center
4542
};
4643
entry.TextChanged += Entry_TextChanged;
4744
return entry;
4845
}
49-
return null;
50-
46+
47+
return new Label { Text = "Unsupported Field" }; // Avoid returning null
5148
}
5249

53-
private void Entry_TextChanged(object sender, TextChangedEventArgs e)
50+
private void Entry_TextChanged(object? sender, TextChangedEventArgs e)
5451
{
55-
if(sender is InputView entry && dataFormCustomItem!=null)
52+
if (sender is InputView entry && dataFormCustomItem is not null)
5653
{
5754
this.CommitValue(dataFormCustomItem, entry);
5855
}

CustomEditor/CustomEditor.csproj

Lines changed: 10 additions & 5 deletions
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>CustomEditor</RootNamespace>
1010
<UseMaui>true</UseMaui>
1111
<SingleProject>true</SingleProject>
1212
<ImplicitUsings>enable</ImplicitUsings>
13+
<Nullable>enable</Nullable>
1314

1415
<!-- Display name -->
1516
<ApplicationTitle>CustomEditor</ApplicationTitle>
@@ -58,9 +59,13 @@
5859
</ItemGroup>
5960

6061
<ItemGroup>
61-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
62-
<PackageReference Include="Syncfusion.Maui.DataForm" Version="23.1.40" />
63-
<PackageReference Include="Syncfusion.Maui.Picker" Version="23.1.44" />
62+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="*" />
63+
<PackageReference Include="Syncfusion.Maui.DataForm" Version="*" />
64+
<PackageReference Include="Syncfusion.Maui.Picker" Version="*" />
65+
</ItemGroup>
66+
67+
<ItemGroup>
68+
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
6469
</ItemGroup>
6570

6671
</Project>

CustomEditor/CustomEditor.csproj.user

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

CustomEditor/MainPage.xaml

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

89
<Grid Background="White">

0 commit comments

Comments
 (0)