Skip to content

Unseal Avalonia.Data.MultiBinding to allow derived classes #21097

Description

@Kryptos-FR

Is your feature request related to a problem? Please describe.

Before Avalonia 12.0, it was possible to derive from Avalonia.Data.MultiBinding. One of the main benefit was the ability to make it work using a shorter and user-friendlier syntax for multi bindings. It was also based on the same feature being possible in WPF using a similar derivation. Since we are porting a lot of code from WPF (for the cross-platform version of the Stride GameStudio), having the same ability was a huge benefit.

Here is an example:

<Button IsVisible="{sd:MultiBinding {Binding ActiveVersion.DownloadCommand.IsEnabled},
                                    {Binding !ActiveVersion.CanStart},
                                     Converter={sd:AndMulti}}" />

The equivalent using allowed syntax is:

<Button>
  <Button.IsVisible>
    <MultiBinding Converter="{sd:AndMulti}">
      <Binding Path="ActiveVersion.DownloadCommand.IsEnabled" />
      <Binding Path="!ActiveVersion.CanStart" />
    </MultiBinding>
  </Button.IsVisible>
</Button>

It is uglier, more verbose and less practical. Now imagine if you have dozen of properties of a object where you need multi bindings.

Note that it was working fine in Avalonia 11 with compiled bindings.

Describe the solution you'd like

Remove the sealed modifer from Avalonia.Data.MultiBinding to restore the ability to derive from it.

Alternatively, would you consider accepting a PR that adds constructors to Avalonia.Data.MultiBinding as well as an implementation of the ProvideTypedValue() method so that we don't have to use the full-form which is unpractical.

Describe alternatives you've considered

Stay forever on Avalonia 11.

Additional context

Here is how it was implemented in WPF: Stride.Core.Presentation.Wpf/MarkupExtensions/MultiBinding.cs as well as in Avalonia 11: Stride.Core.Presentation.Avalonia/MarkupExtensions/MultiBinding.cs

This is somehow related to #17621, though the syntax is different.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions