-
Notifications
You must be signed in to change notification settings - Fork 810
Labels
area/xBind 🪢Categorizes an issue or PR as relevant to x:BindCategorizes an issue or PR as relevant to x:Binddifficulty/medium 🤔Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUICategorizes an issue for which the difficulty level is reachable with a good understanding of WinUIproject/binding 🪢Categorizes an issue or PR as relevant to the binding engineCategorizes an issue or PR as relevant to the binding engine
Description
Current behavior 🐛
The targetType
the IValueConverter
received is null when bind back with a enum type.
EnumBindBack.zip
Expected behavior 🎯
No response
How to reproduce it (as minimally and precisely as possible) 🔬
No response
Workaround 🛠️
Use {Binding}
instead of x:Bind
Renderer 🎨
- Skia
- Native
Implementation info
The issue stems from the fact that the x:Bind
expression generates the following C# code:
global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, ___t, ___ctx => ___ctx is global::EnumBindBack.MainPage ___tctx ? ((true, ___tctx.SelectedItem)) : (false, default), (___ctx, __value) => { if(___ctx is global::EnumBindBack.MainPage ___tctx) ___tctx.SelectedItem = (global::EnumBindBack.ItemEnum)global::Microsoft.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(global::EnumBindBack.ItemEnum), __value); } , new [] {"SelectedItem"})
This code uses lambdas for value retrieval and bind back, but does not include information about the source property type.
Ultimately it seems we will need to add an additional parameter like sourceType
, which will then flow to SetBindingXBindProvider
method and will be used as the targetType
for ConvertBack
method.
Copilot
Metadata
Metadata
Assignees
Labels
area/xBind 🪢Categorizes an issue or PR as relevant to x:BindCategorizes an issue or PR as relevant to x:Binddifficulty/medium 🤔Categorizes an issue for which the difficulty level is reachable with a good understanding of WinUICategorizes an issue for which the difficulty level is reachable with a good understanding of WinUIproject/binding 🪢Categorizes an issue or PR as relevant to the binding engineCategorizes an issue or PR as relevant to the binding engine