-
Couldn't load subscription status.
- Fork 773
Open
Labels
area-Bindingarea-XamlCompilerfeature proposalNew feature proposalNew feature proposalneeds-winui-3Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)product-winui3WinUI 3 issuesWinUI 3 issuesteam-MarkupIssue for the Markup teamIssue for the Markup team
Description
Proposal: x:Bind functions should support calling another function within its parameter list
From comment here, Related #1630
Summary
It's difficult to do complex expressions in x:Bind to composite to UI triggers/converter replacement type scenarios from back-end model data.
Rationale
- By allowing x:Bind to chain functions within parameters, we can perform other calculations that would normally need extra converter or trigger code to perform.
- A developer would be able to keep logic in context where it's used rather than obscuring it in another class.
- Would be more performant to compile the expression down in the one-line in the generated code vs. creating a whole bunch of new objects and lookups to perform at runtime.
Scope
| Capability | Priority |
|---|---|
| Able to call another local/static function within one or more parameter arguments to another local/static function within an x:Bind expression | Must |
| Inner functions can also accept the same binding or constant expression parameters that x:Bind accepts today | Must |
| No (practical) limit on the number of nested functions called | Should |
Able to continue a chain on to the function expression with other method calls e.g. {x:Bind myns:StaticClass.DoConversion(ViewModel.Data).ToString()} |
Should |
| Can also do the same in the bindback expression | Should |
Examples
{x:Bind myns:StaticClass.DoConversion(ViewModel.Data).ToArrayHelper().ToString()}
{x:Bind myns:Helpers.Compare(Data.ToString(), "SomeString", Comparison.Equal)}
{x:Bind myns:Helpers.ToVisibility(LookupValue(MyData.SomeProperty))}
{x:Bind MakeBrush(ReadTextColor(Data.HexStringColor))}
{x:Bind myns:StaticClass.Food(myns:StaticClass.Bar(ViewModel))}
Open Questions
Sergio0694, matthew4850, Panda-Sharp, yoshiask, Felix-Dev and 8 moreRobbyRobbyRobby, Sergio0694, shweaver-MSFT and UsergitbitSergio0694 and Usergitbit
Metadata
Metadata
Assignees
Labels
area-Bindingarea-XamlCompilerfeature proposalNew feature proposalNew feature proposalneeds-winui-3Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)product-winui3WinUI 3 issuesWinUI 3 issuesteam-MarkupIssue for the Markup teamIssue for the Markup team