dotnet / dotnet/wpf

Support DataAnnotations and TagHelpers in WPF

Open
#2,256 4 comments 3 reactions 0 assignees View on GitHub
Design Discussion
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

I suggest that you allow using the attributes defined in System.ComponentModel.DataAnnotations with any property in a wpf project, like ASP.NET does. For example:
```C#
[Required]
[MinLength(2)]
[MaxLength(12)]
public string FirstName { get; set; }
```
ASP.NET generates server side validation code for these attributes (beside the client side validation scripts), so, I think you can make WPF borrow the class that generates the server side code to achieve this. Note: There are some attributes used with tag helpers to affect the UI such as DisplayAttribute. I think XAML should also add the tag helpers concept too. I find it easier and shorter than the currently used data binding.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.