Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/develappersgmbh/xform
Form builder for Xamarin.Android and Xamarin.iOS. Define your form in the shared project and use and customize it on both platforms. Strongly influenced by https://github.com/xmartlabs/Eureka.
https://github.com/develappersgmbh/xform
forms xamarin xamarin-android xamarin-ios
Last synced: about 1 month ago
JSON representation
Form builder for Xamarin.Android and Xamarin.iOS. Define your form in the shared project and use and customize it on both platforms. Strongly influenced by https://github.com/xmartlabs/Eureka.
- Host: GitHub
- URL: https://github.com/develappersgmbh/xform
- Owner: DevelappersGmbH
- License: mit
- Created: 2018-12-29T14:57:20.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-16T18:11:33.000Z (about 6 years ago)
- Last Synced: 2024-11-14T14:44:04.738Z (2 months ago)
- Topics: forms, xamarin, xamarin-android, xamarin-ios
- Language: C#
- Homepage:
- Size: 309 KB
- Stars: 2
- Watchers: 12
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XForm
[![NuGet](https://img.shields.io/nuget/v/XForm.svg)](https://www.nuget.org/packages/XForm/)
## What is XForm
XForm provides tools to create forms quickly and easily. Simply create a form model and bind it to the provided UI controls.
## Getting started
### Install
Grab the latest [XForm NuGet package](https://www.nuget.org/packages/XForm/) and install in your solution.
### Create your first form
#### Register XForm
Call in your setup code for andorid:
```csharp
AndroidForm.Register();
```and for ios:
```csharp
IosForm.Register();
```#### Define your first form with the FormModel
The form consists of multiple fields. Which fields are displayed is defined by the FormModel. Different field types are available, but it is also possible to create your own field types.
What a FormModel for a login form could look like:
```csharp
public class LoginFormModel: XForm.Forms.FormModel
{
public LoginFormModel()
{
LoginCommand = new MvxCommand(HandleLoginCommand, IsValid);
}[EmailAddressTextField("E-Mail Address")]
public string EmailAddress { get; set; }[PasswordTextField("Password")]
public string Password { get; set; }[ButtonField("Login")]
public IMvxCommand LoginCommand { get; }protected override void FieldValueChanged()
{
LoginCommand.RaiseCanExecuteChanged();
}public bool IsValid()
{
return EmailAddress.IsValidEmailAddress()
&& Password.IsSavePassword();
}public void HandleLoginCommand()
{
// Do login
}
}
```The attributes above the properties determine which fields are displayed. The following attributes are available:
* LabelFieldAttribute
* Number input
* DecimalInputFieldAttribute
* NumberInputFieldAttribute
* Text input
* SingleLineTextFieldAttribute
* PasswordTextFieldAttribute
* EmailAddressTextFieldAttribute
* OptionPickerFieldAttribute
* ButtonFieldAttribute#### Create the Form from your FormModel
Only two steps are necessary to create the form.
```csharp
// First, instantiate your FormModel
var formModel = new LoginFormModel();// Second, create the form with the FormModel
Form = Form.Create(formModel);
```The best place for this is the ViewModel, so the form can be used under both platforms.
#### Display your first Form
With XForm comes the FormView control for the platforms Xamarin.Android and Xamarin.iOS. This control is an extended UITableView respectively RecyclerView. Just add this control to your layout and set (or bind) the FormView's Form property.
## More examples
Complete form examples can be found in the [Sample Projects](Sample) folder.
## Contribution
Bug reports and pull requests are welcome.