|
1 | 1 | ---
|
2 |
| -description: Learn about using functions as the leaf step of the data binding path in the xBind markup extension. |
3 |
| -title: Functions in x:Bind with Windows App SDK |
4 |
| -ms.date: 12/13/2022 |
5 |
| -ms.topic: article |
6 |
| -keywords: windows 10, windows 11, windows app sdk, xaml, winui, windows ui, xBind |
| 2 | +description: Learn about using functions as the leaf step of the data binding path in the xBind markup extension in WinUI apps with the Windows App SDK. |
| 3 | +title: Functions in x:Bind with WinUI |
| 4 | +ms.date: 07/30/2025 |
| 5 | +ms.topic: concept-article |
| 6 | +keywords: windows 10, windows 11, windows app sdk, xaml, winui, windows ui, xBind, winui 3 |
7 | 7 | ms.localizationpriority: medium
|
| 8 | +# Customer intent: As a Windows developer, I want to learn how to use functions in x:Bind so that I can simplify value conversion and create more complex bindings in my WinUI apps. |
8 | 9 | ---
|
9 | 10 |
|
10 |
| -# Functions in x:Bind with Windows App SDK |
| 11 | +# Functions in x:Bind with WinUI |
11 | 12 |
|
12 | 13 | > [!NOTE]
|
13 | 14 | > For general info about using data binding in your app with `{x:Bind}` (and for an all-up comparison between `{x:Bind}` and `{Binding}`), see [Data binding in depth](data-binding-in-depth.md) and [{x:Bind} Markup Extension](/windows/uwp/xaml-platform/x-bind-markup-extension).
|
14 | 15 |
|
15 |
| -In Windows App SDK apps, **{x:Bind}** supports using a function as the leaf step of the binding path. This enables: |
| 16 | +In WinUI apps, **{x:Bind}** supports using a function as the leaf step of the binding path. This enables: |
16 | 17 |
|
17 | 18 | - A simpler way to achieve value conversion
|
18 | 19 | - A way for bindings to depend on more than one parameter
|
@@ -168,6 +169,9 @@ Multiple function arguments can be specified, separated by comma's (,)
|
168 | 169 | - Constant Number - for example -123.456
|
169 | 170 | - Boolean – specified as "x:True" or "x:False"
|
170 | 171 |
|
| 172 | +> [!TIP] |
| 173 | +> [TargetNullValue](/windows/uwp/xaml-platform/x-bind-markup-extension#properties-that-you-can-set-with-xbind) will apply to the result of the function call, not to any bound arguments. |
| 174 | +
|
171 | 175 | ### Two way function bindings
|
172 | 176 |
|
173 | 177 | In a two-way binding scenario, a second function must be specified for the reverse direction of the binding. This is done using the `BindBack` binding property. In the below example, the function should take one argument which is the value that needs to be pushed back to the model.
|
|
0 commit comments