This project is read-only.

Basic Usage

There are a few ways to implement AutoForm, each one gives you more control over how things work.

XAML Static Resources

About the easiest way to use AutoForm involves creating a data context object, an instance of ModelObjectFormDefiner and an AutoFormPanel control:
  1. Create a model object. For a simple app this might be a single static resource in App.xaml, or it may be an object returned by a ViewLocator in the MVVM pattern.
  2. Create a ModelObjectFormDefiner and set the ModelObject property to your model object
  3. Insert an AutoFormPanel control in your XAML at the location you want the form to be created, and set its ModelObjectFormDefiner property to the ModelObjectFormDefiner instance created in step 2

That's enough to create a data entry form for the writeable properties in the model object. You'll get an input form whose controls are laid out in a grid, with one control per writeable property. Labels should be a human-readable form of the property name.

XAML Field Definitions

Instead of using a ModelObjectFormDefiner, you can specify the field definitions for your form explicitly in XAML. To do this, create an instance of FieldDefinitionList as a static resource (you'll need to add the AutoForm and AutoForm.FieldDefinitions as XML namespaces - here they're called af and afdefs respectively):

        <af:FieldDefinitionList x:Key="FieldDefs">
            <afdefs:TextFieldDefinition PropertyName="FirstName" />
            <afdefs:TextFieldDefinition PropertyName="LastName"  />
            <afdefs:DateFieldDefinition PropertyName="DateOfBirth" Newline="True" />
            <afdefs:CheckBoxFieldDefinition PropertyName="Authorised" />
            <afdefs:PasswordFieldDefinition PropertyName="Password" />
            <afdefs:PasswordFieldDefinition PropertyName="ConfirmPassword" />

To use these field definitions, reference the FieldDefinitionList in an instance of AutoFormPanel:

        <af:AutoFormPanel x:Name="SignupFormPanel" 
                          FieldDefinitions="{StaticResource FieldDefs}" />

Last edited Oct 20, 2014 at 8:36 AM by DevKnightlie, version 2