Once the project has been created, perform the following steps to learn static binding:
- Open the MainWindow.xaml page and add a Label inside the Grid panel. Give it a background color (let's say, OrangeRed) and run the application. This is what we use most often to write hardcoded values inline:
<Label Background="OrangeRed" Content="Kunal Chowdhury" FontSize="25" Width="300" Height="60" Padding="10" Margin="10"/>
- Now, let's change it to set a background color from the system defined colors. To do this, we need to use {x:Static} markup extension to access the static properties. Here's how the code will be changed:
<Label Background="{x:Static SystemColors.ControlDarkBrush}" Content="Kunal Chowdhury" FontSize="25" Width="300" Height="60" Padding="10"...