Skip to content

Commit 07d107f

Browse files
Merge pull request #1 from SyncfusionExamples/Resolved-Sample-Issue
Added the Missed Model Class into this Sample.
2 parents 2f6320f + 87c2374 commit 07d107f

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

CustomEditor/CustomDataEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public View CreateEditorView(DataFormItem dataFormItem)
2929
var view = new Image()
3030
{
3131
Source=(dataFormItem.BindingContext as DataFormViewModel).ContactFormModel.ProfileImage,
32-
HorizontalOptions=LayoutOptions.Start,
32+
HorizontalOptions=LayoutOptions.Center,
3333
HeightRequest=80,
3434
WidthRequest=80
3535
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#region Copyright Syncfusion Inc. 2001-2023.
2+
// Copyright Syncfusion Inc. 2001-2023. All rights reserved.
3+
// Use of this code is subject to the terms of our license.
4+
// A copy of the current license can be obtained at any time by e-mailing
5+
// licensing@syncfusion.com. Any infringement will be prosecuted under
6+
// applicable laws.
7+
#endregion
8+
namespace CustomEditor
9+
{
10+
using Syncfusion.Maui.DataForm;
11+
using System.ComponentModel.DataAnnotations;
12+
13+
/// <summary>
14+
/// Represents the model class for contact form.
15+
/// </summary>
16+
public class ContactFormModel
17+
{
18+
public ContactFormModel()
19+
{
20+
this.ProfileImage = "people_circle16.png";
21+
this.Name = string.Empty;
22+
this.LastName = string.Empty;
23+
this.Address = string.Empty;
24+
this.City = string.Empty;
25+
this.State = string.Empty;
26+
this.Email = string.Empty;
27+
this.Mobile = string.Empty;
28+
this.Landline = string.Empty;
29+
this.ZipCode = string.Empty;
30+
}
31+
32+
[DataFormDisplayOptions(ColumnSpan = 2, ShowLabel = false)]
33+
public string ProfileImage { get; set; }
34+
35+
[Display(ShortName = "First name", GroupName ="Name")]
36+
[Required(ErrorMessage = "Name should not be empty")]
37+
public string Name { get; set; }
38+
39+
[Display(ShortName = "Last name", GroupName ="Name")]
40+
public string LastName { get; set; }
41+
42+
[Display(GroupName ="Mobile")]
43+
[DataType(DataType.PhoneNumber)]
44+
[Required]
45+
[RegularExpression(@"^\(\d{3}\) \d{3}-\d{4}$", ErrorMessage = "Invalid phone number")]
46+
public string Mobile { get; set; }
47+
48+
[Display(GroupName = "Mobile")]
49+
[DataType(DataType.PhoneNumber)]
50+
public string Landline { get; set; }
51+
52+
[Display(GroupName = "Address")]
53+
[DataFormDisplayOptions(ColumnSpan = 2)]
54+
public string Address { get; set; }
55+
56+
[Display(GroupName = "Address")]
57+
[DataFormDisplayOptions(ColumnSpan = 2)]
58+
public string City { get; set; }
59+
60+
[Display(GroupName = "Address")]
61+
public string State { get; set; }
62+
63+
[Display(ShortName = "Zip code", GroupName = "Address")]
64+
public string ZipCode { get; set; }
65+
66+
public string Email { get; set; }
67+
68+
}
69+
}

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
1-
# How-to-add-an-image-to-the-.NET-MAUI-DataForm-Editors
2-
The sample demonstrates how to add an image and create custom editors in the .NET MAUI DataForm editors.
1+
# How-to-add-Custom-Editor-to-the-.NET-MAUI-DataForm-Control
2+
A quick-start project that guides you in integrating a DataForm control with a Custom Editor in a .NET MAUI application by adding the Syncfusion MAUI DataForm package from NuGet. This project includes code on how to add an image and register a custom editor for the field name.
3+
4+
Refer to the following documentation for the Syncfusion .NET MAUI DataForm control: https://help.syncfusion.com/maui/dataform/editors#custom-editor
5+
6+
Check out this GitHub example for the Syncfusion .NET MAUI DataForm control: https://github.com/syncfusion/maui-demos/blob/master/MAUI/DataForm
7+
8+
# Project prerequisites
9+
Make sure that you have the compatible versions of Visual Studio 2022 with the Dot NET MAUI workload and .NET Core SDK 7.0 or later version in your machine before starting to work on this project.
10+
11+
# How to run this application
12+
To run this application, you need to first clone the repository How-to-add-an-image-to-the-.NET-MAUI-DataForm-Editors and then open it in Visual Studio 2022. Now, simply build and run your project to view the output.

0 commit comments

Comments
 (0)