Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Introduce AutoFormView #586

Merged
merged 9 commits into from Feb 23, 2024
Merged

Introduce AutoFormView #586

merged 9 commits into from Feb 23, 2024

Conversation

enisn
Copy link
Owner

@enisn enisn commented Feb 23, 2024

Usage

public class AutoFormViewPageViewModel : ViewModelBase
{
    [Reactive] public string Email { get; set; }
    [Reactive] public string FullName { get; set; }
    [Reactive] public Gender Gender { get; set; }
    [Reactive] public DateTime? BirthDate { get; set; }
    [Reactive] public TimeSpan? MeetingTime { get; set; }
    [Reactive] public int? NumberOfSeats { get; set; }
    [Reactive] public bool IsTermsAndConditionsAccepted { get; set; }
}
<uranium:AutoFormView Source="{Binding .}" />

image


Validations Support

builder.Services.Configure<AutoFormViewOptions>(options =>
{
    options.ValidationFactory = DataAnnotationValidation.CreateValidations;
});

Configure your own editors:

builder.Services.Configure<AutoFormViewOptions>(options =>
{
    options.EditorMapping[typeof(string)] = (property, source) =>
    {
        var editor = new Entry();
        editor.SetBinding(Entry.TextProperty, new Binding(property.Name, source: source));
        return editor;
    };

    options.EditorMapping[typeof(int)] = (property, source) =>
    {
        var editor = new Stepper();
        editor.SetBinding(Stepper.Value, new Binding(property.Name, source: source));
        return editor;
    };
});

@enisn enisn added this to the v2.8 milestone Feb 23, 2024
@enisn enisn merged commit 8b3da0c into develop Feb 23, 2024
3 checks passed
@enisn enisn deleted the autoformview branch February 23, 2024 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant