unoplatform / uno

Build Mobile, Desktop and WebAssembly apps with C# and XAML. Today. Open source and professionally supported.
https://platform.uno
Apache License 2.0
8.78k stars 706 forks source link

x:Bind `Converter.ConvertBack` is missing the type parameter #7174

Open alove-kahua opened 2 years ago

alove-kahua commented 2 years ago

Current behavior

Using a TwoWay x:Bind on SelectedIndex does not update the target with the new index.

Expected behavior

The target of the bind gets updated.

How to reproduce it (as minimally and precisely as possible)

ComboBoxSelectedIndex.zip

Run the wasm project and notice both the bind with a converter and without fails to update the target value.

Workaround

No response

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

jeromelaban commented 2 years ago

Two possible workarounds here:

Note for contributors

This binding engine is not providing the target type properly because of the x:Bind. The BindingExpression._bindingPath.ValueType field is empty, because x:Bind expressions don't have a path defined.

Fixing this requires to invoke the converted in the generated code, in place of the current conversion: https://github.com/unoplatform/uno/blob/b5971df6df15057d2e3e8da4bf89f391c5dfa03c/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs#L3927.

Note that converter parameter would also need to be handled properly here.