Website Updatestrainz Forge



  1. Getting started

'Webforge did a first-rate job updating my firm’s website and making it more user-friendly. They're easy to work with, efficient and extremely knowledgeable. I highly recommend them.' Kevin Cott, Esq. Cott Law Group P.C. 'Webforge's flair for design and thorough understanding of the web provided us an excellent opportunity. Ecommerce Web Design. At Websiteforge.com, ecommerce and web design go hand in hand. Our team of brilliant web designers, custom programmers, graphic artists, business development professionals and marketing guru's have worked together to bring the world a truly exceptional ecommerce solution.

Using this library is straightforward. DynamicForm is a control that will render controls bound to an associated model. A model can be an object, a type, a primitive, or a custom IFormDefinition.

A DynamicForm has two key properties, the Model property, which represents the form being rendered, and the Context property, which allows models to access data outside of their scope, such as a selection field or action handling.

Hosting dynamic forms

DynamicForm is a WPF control that hosts forms. You are free to include this control anywhere in XAML:

As you can see above, MVVM patterns are fully supported. In this way, you can expose your data from a ViewModel, and the view for manipulating that data is automatically rendered.

If you only need to display the forms as dialogs, then you can use helper class Forge.Forms.Show like this:

Show.Dialog() will host the form in a MaterialDesignInXAML DialogHost control, while Show.Window() will host the control in a Mahapps.Metro window.

Building forms from classes

The easiest way to build a form is to declare a class with the inputs you need. You can use annotations to fine-tune the behavior of fields, or even add form elements such as titles, text, or actions.

In the following class we declare a Login model:

Most of the decorators should be self-explanatory. If we call Show.Dialog().For<Login>(), we will see the following dialog:

Calling Show.Window().For<Login>() will show the same form, except that it will be hosted in a new window.

If we want to manually display this form in XAML, we would have to write:

Updatestrainz

Trainz Freeware Website

Where MyLoginModel would be a property that returned a Login instance, or even the typeof(Login) itself.

Imperatively, this could be done via:

Updatestrainz

If you are not sure if the model is a type or an instance, reading MyForm.Value will always return the resolved instance of the input model.

Common form helpers

Because some simple dialogs are so common, we offer built-in helper classes for them:

  • Alert - displays a message and a button
  • Confirmation - displays a message and up to two buttons
  • Prompt<T> - displays a message, an input field, and up to two buttons

Examples:

Demo project

We offer a demo with a lot of examples to help you get started.

For every model you see in the list of examples, you can view its source from the top right menu:

To run the demo, clone the repository:

Trainz Sites

And open Forge.Forms/Forge.Forms.sln, then run Forge.Forms.Demo project.

Trainz Forge Old Site

Back to top