Зміст курсу
Advanced C# with .NET
1. Introduction to Desktop Development with .NET
Advanced C# with .NET
Task - Practicing Data Binding
In the base code's XAML, there are two elements, one of them is a Checkbox, while the other is a Label.
Your task is to bind the Checkbox's IsChecked
property with the Label's Text
property such that, when the Checkbox is checked, it sets the Label to "Is checkbox checked? True" and if it's not then the Label is set to "Is checkbox checked? False".
You only have to modify the C# file.
Hint 2: We use the following syntax for binding properties:
targetElement.SetBinding(TargetElementType.TargetProperty, new Binding(“path to property”, source: sourceElement);
namespace MAUIDataBindingTask
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
mainLabel.SetBinding(Label.TextProperty, new Binding("IsChecked", source: mainCheckbox, stringFormat: "Is checkbox checked? {0}"));
}
}
}
Все було зрозуміло?
Зміст курсу
Advanced C# with .NET
1. Introduction to Desktop Development with .NET
Advanced C# with .NET
Task - Practicing Data Binding
In the base code's XAML, there are two elements, one of them is a Checkbox, while the other is a Label.
Your task is to bind the Checkbox's IsChecked
property with the Label's Text
property such that, when the Checkbox is checked, it sets the Label to "Is checkbox checked? True" and if it's not then the Label is set to "Is checkbox checked? False".
You only have to modify the C# file.
Hint 2: We use the following syntax for binding properties:
targetElement.SetBinding(TargetElementType.TargetProperty, new Binding(“path to property”, source: sourceElement);
namespace MAUIDataBindingTask
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
mainLabel.SetBinding(Label.TextProperty, new Binding("IsChecked", source: mainCheckbox, stringFormat: "Is checkbox checked? {0}"));
}
}
}
Все було зрозуміло?