dotnet / dotnet/wpf

Better API for overriding metadata.

Open
#2,380 1 comment 0 reactions 0 assignees View on GitHub
Enhancement Requested
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

Currently it looks like:
```cs
DefaultStyleKeyProperty.OverrideMetadata(
typeof(Button),
new FrameworkPropertyMetadata(typeof(Button)));
```

The problem is that when overriding caller needs to know the type of metadata registered to avoid:

```
ArgumentException: Metadata override and base metadata must be of the same type or derived type.
```

Overriding default value is common and we could add new API so that the framework figures out what metadata type to use:

```cs
DefaultStyleKeyProperty.OverrideDefaultValue(
typeof(Button),
typeof(Button)); // The framework then calls OverrideMetadata with the correct type.
```

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.