Starter exercises
Now that you have built a temperature converter app, try these three exercises to test your understanding of Avalonia.
Exercise 1: Change an existing attribute
Challenge level: ★
Make the gridlines invisible in GetStartedApp.
Hint
You specified <Grid> in MainWindow.axaml.
Solution
In MainWindow.axaml, locate the <Grid> opening tag. Change the ShowGridLines attribute to False.
<Grid ShowGridLines="False" Margin="5"
ColumnDefinitions="120, 100"
RowDefinitions="Auto, Auto, Auto">
Exercise 2: Add a new attribute
Challenge level: ★★
Make it impossible for a user to input text into the Fahrenheit text box in GetStartedApp.
Hint (1st)
Check the API docs for more information on the TextBox control.
Hint (2nd)
Under the API reference for TextBox, you’ll find the attribute IsReadOnly.
Solution
In MainWindow.axaml, locate the <TextBox> tag for the Fahrenheit box. Add the IsReadOnly attribute, and set it to True.
<TextBox Grid.Row="1" Grid.Column="1" Margin="0 5" Text="0" Name="Fahrenheit" IsReadOnly="True"/>