Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/usercode/wpf.dataforms
Fluent-based data forms for WPF
https://github.com/usercode/wpf.dataforms
wpf
Last synced: 3 days ago
JSON representation
Fluent-based data forms for WPF
- Host: GitHub
- URL: https://github.com/usercode/wpf.dataforms
- Owner: usercode
- License: mit
- Created: 2018-08-07T12:23:09.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2022-12-29T20:32:49.000Z (almost 2 years ago)
- Last Synced: 2024-10-02T16:37:37.426Z (about 1 month ago)
- Topics: wpf
- Language: C#
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WPF.DataForms
Fluent-based data forms for WPFhttps://www.nuget.org/packages/WPF.DataForms
[![nuget](https://img.shields.io/nuget/v/WPF.DataForms.svg)](https://www.nuget.org/packages/WPF.DataForms)
## General ##
- Every form has groups and fields
- Every form has three states (view, create and edit)
- Every field create different controls depended by state
- View state: e.g. some controls are just disabled or replaced by non-editable controls.
- Automatic grid layout
- add or move fields and groups without setting the row and column number
- Easily replace controls without changing mappings## How to use it ##
1. Create the entity detail viewmodel
```CS
class CustomerDetailViewModel
{
public Customer Customer { get; set; }
public DataTemplate DataTemplate { get; set; }
//..
}
```2. Create the entity detail view and set the data context to the viewmodel instance.
```XAML
```
3. Define the mapping for viewmodel
```CS
class CustomerFormMapping : DataFormMapping
{
public override void CreateContent()
{
MainContent.Group(Resources.General)
.Id(Resources.Id, x => x.Customer.Id)
.Bool(Resources.IsActive, x => x.Customer.IsActive)
.Text(Resources.Title, x => x.Customer.Title)
.Text(Resources.LastName, x => x.Customer.Lastname)
.Text(Resources.FirstName, x => x.Customer.Firstname)
.Date(Resources.DateOfBirth, x => x.Customer.DOB)
;
}
```4. Create the data template:
```CS
viewModel.DataTemplate = new CustomerFormMapping ().CreateTemplate(FormState.View);
```