Data Binding
Avalonia includes comprehensive support for binding between controls and to arbitrary .NET objects. Data binding can be set up in XAML or in code and supports:
The following example shows a TextBlock when an associated TextBox is disabled, by using a binding:
1
<StackPanel>
2
<TextBox Name="input" IsEnabled="False"/>
3
<TextBlock IsVisible="{Binding !#input.IsEnabled}">Sorry, no can do!</TextBlock>
4
</StackPanel>
Copied!
In this example, a binding is set up to the IsEnabled property of the input control using #input.IsEnabled and the value of that binding is negated and fed into the TextBlock.IsVisible property.
Last modified 2mo ago
Export as PDF
Copy link