dotnet / dotnet/wpf

Add an markup extension to bind standard values of a type

Open
#655 2 comments 1 reaction 0 assignees View on GitHub
API suggestion Enhancement Requested
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

A long time ago I wrote [Enumerate](https://github.com/YohDeadfall/Enumerate) which is designed to provide standard values of any type if it supports it. It's used mostly for `enum`s, but as I said it isn't limited to them. And because WPF is open source now, I think it's time to make the markup extension built-in so everyone will be able to use out of the box.

## Features

1. Providing values of an `enum` as is.
2. Providing values of an `enum` from `DescriptionAttribute`s.
1. Providing values of any type whose `TypeConverter` returns the standard values via the `GetStandardValues` method.

## Usage:

```csharp

public enum ViewModelStatus
{
[Description("Offen")]
Open,
[Description("Geschlossen")]
Closed,
[Description("In Arbeit")]
InProgress
}

public class ViewModel : INotifyPropertyChanged
{
public ViewModelStatus Status { get; set; }
}

```

```xaml

```

---

Related to #455.

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.