dotnet / dotnet/wpf

Open up the Binding API for more extensibility

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

Description

Something that troubles me for a long time since starting with WPF is the fact, that the binding API is very restricted and limited in extensibility.

In our software we use a custom markup (MarkupExtension derivate) which uses a *Key* and *Context* string that defines where in the language file the translated string can be found. For ease-of-use and usability the keys are grouped. To make things easy and keep it natural, the markup walks through the logic tree and looks up all attached properties so I can inherit the context on each element level in the XAML structure which fits the tree hierarchy of the language file.

Now I have scenarios where I bind to a certain value and need to display a translated fallback string when the binding is invalid/null. This cannot be done since I need the logic implemented in my MarkupExtension in order to retrieve the correct context (logic tree lookup). Using a `PriorityBinding` would be the way to go, but this only supports elements of type `BindingBase` of which `MarkupExtension` is the base-class. So the only clean approach would be implementing a custom Binding (or overriding the Binding-class) which has this logic in order to return an actual translated FallbackValue.

As of now this is not possible since `BindingBase` is completely sealed off (by having an internal constructor that cannot be inherited) while Binding exposes none of it's properties and methods for overridden logic.

It would be truly helpful if this API was opened up for more extensibility. There's still a lot of potential in it. Now with .Net Core this could actually be done.

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.