Window
class. The x:Class
attribute is used to associate the markup with the code-behind class. InitializeComponent
is called from the code-behind class's constructor to merge the UI that is defined in markup with the code-behind class.
You could notice MainWindow
class is declared as partial
and there is no InitializeComponent
implementation visible. That's because InitializeComponent
body was auto-generated at the partial class counterpart by the Avalonia.NameGenerator package which is included with Avalonia templates by default.x:Class
and InitializeComponent
ensure that your implementation is correctly initialised whenever it is created. The code-behind class also implements an event handler for the button's Click
event. When the button is clicked, the event handler changes the text of the button by setting a property on the Button
control.