Skip to content

Dynamically generated forms and dialogs in WPF and Avalonia UI.

License

Notifications You must be signed in to change notification settings

SachiHarshitha/Forge.Forms

Β 
Β 

Repository files navigation

Forge.Forms.AvaloniaUI

NuGet

πŸ“– About

With Forge.Forms you can create dynamic forms in WPF from classes or XML. 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.

Given the flexibility it provides especially in MVVM based applications, Sachith Liyanagama, is currently porting the project into the * Avalonia framework*.

To get started, check out the original guide for now. Avalonia-Specific guide will be documented later. or follow the installation instructions below.

πŸ“· Screenshots

Cross Platform User Interface (Demo Project)

Desktop WASM

Data Types & Control Components

Type Sub Types Screenshot
String String, Password, Multiline image
Numerical Numeric Up Down
Slider
Date image
Time image
Selection Radio Buttons
Editable Combobox
Boolean Toggle Switch
Checkbox

⚠️ Warning

Due to the original WPF-Based library ships with dependencies to UI toolkits such as Material Design, there can be certain bottlenecks. Please consider this project/repository to be experimental until a better and cleaner approach has been developed.

πŸš€ Avalonia PORTING Log

Due to the complex usage of deferred bindings in the original project, porting to avalonia is done incermentally. Similarly based on the functionality the components are classified as follows.

Control Components

First iteration of the controls are ported using basic Fluent Theme styling and later need to be ported to CONTROL THEMES.

Control Type Status Comment
Action Element 🎌 Ported
Boolean Field 🎌 Ported
Break Element 🎌 Ported
Card Element 🎌 Ported Dependency to Card Component of Material Design, need to work on sizing.
Converted Field 🎌 Ported Need to test more
Date Field 🎌 Ported Must use DateTimeOffset for the bound properties instead of DateTime
Time Field 🎌 Ported Avalonia Returns DateTime offset. Need to change the Resource type
Divider Element 🎌 Ported
Error Text Element πŸ’€ Will be removed Do not needed.
Heading Element 🎌 Ported
Image Element 🎌 Ported Need to copy image to the "Assets" folder and write path in the format of: [Image("avares://(AssemblyName)/Assets/(filename)")]
Selection Field 🎌 Ported Dynamic Binding not available due to Binding Incompatibilities
Slider Field 🎌 Ported
Text Element 🎌 Ported WASM seems to not handle the MultiBinding Strings.
Title Element 🎌 Ported
Toggle Field 🎌 Ported

Logical Components

Logic Status Comment
Form Builder 🎌 Ported Need more testing
XML Form Builder 🎌 Ported Need more testing. Bindings seems not to work.
Attributes 🎌 Ported Mostly working, other than dynamic property bindings for Selection.
Form Binding Extension 🎌 Recreated Given that the DataContext setting is not set mostly during initialization, had to optimize logic and seperate certain Bindings to use a converter (FormBindingConverter).
Freezable Proxy Objects 🎌 Ported Replaced Ifreezable with avalonia object and pass binding from control.
Dialogs 🎌 Ported Need more testing and style optimization. Window needs to be optimized.
File Binding πŸ’€ Incomplete FileWatcher only works on Desktop. Need to find an alternative.
Data Validation 🎌 Recreated Rewrote the validation logic in a simple manner using a model wrapper, Validation event and DataValidationErrors

Themes

Framework Method Status How to Use
Avalonia - Fluent Styles & Control Theme Currently being optimized xaml <StyleInclude Source="avares://Forge.Forms.AvaloniaUI/Themes/Fluent.axaml" />
Material Styles & Control Theme Currently being optimized xaml <StyleInclude Source="avares://Forge.Forms.AvaloniaUI/Themes/Material.axaml" />

Installation

Import Project Forge.Forms.AvaloniaUI

For default style sheet, add this to App.axaml

<StyleInclude Source="avares://Forge.Forms.AvaloniaUI/Themes/Base.axaml" />

DynamicForm control

If you want to use DynamicForm, import this namespace in XAML:

<xmlns:forms="clr-namespace:Forge.Forms.AvaloniaUI.Controls;assembly=Forge.Forms"/>

And use the control:

<forms:DynamicForm Model="{Binding Model}" />

Displaying Windows

If you only need to show windows and dialogs, use the Show helper:

using Forge.Forms;

await Show.Window().For(new Alert("Hello world!"));

Displaying Dialogs 🚧

using Forge.Forms;

await Show.Dialog().For<Login>(); 

Note: if you are using Show.Dialog() without specifying a dialog identifier, it expects you to have a DialogHost in your XAML tree.

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.2%
  • Other 0.8%