dotnet / dotnet/wpf

Feature Request: Add data binding support for default interface properties (C# 8)

Open
#2,959 14 comments 5 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

C# 8 added support for default interface method and properties. Now we can write the following:
``` c#
public interface ITimeFeature
{
public DateTime CurrentTime => DateTime.Now;
}
class Item : ITimeFeature {}
```

However if we try to data bind to the **Item** object with **Path=CurrentTime**, it will fail to locate the property because it is inherited from the interface and not explicitly defined.

We can easily make this work now by creating a **CustomTypeDescriptor** which includes the defaulted properties. Can you make this built in, so we don't have to resort to writing descriptors?

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.