I have a simple Avalonia form:
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AvaloniaExperiment.MainWindow"
Title="AvaloniaExperiment">
<StackPanel>
<TextBlock>Welcome to Avalonia!</TextBlock>
<Button Name="btn" Click="btn_OnClick">Fred!</Button>
</StackPanel>
</Window>
And a method in the code behind (I want to do things this way until I become familiar with Avalonia, then maybe I'll try MVVM):
private void btn_OnClick()
{
btn.Text = "Ginger";
}
However I get these compile errors:
The name btn does not exist in the current context (in the code behind)
Unable to find suitable setter or adder for property Click of type Avalonia.Controls:Avalonia.Controls.Button for argument System.Private.CoreLib:System.String, available setter parameter lists are: System.EventHandler`1[[Avalonia.Interactivity.RoutedEventArgs, Avalonia.Interactivity, Version=0.9.0.0, Culture=neutral, PublicKeyToken=null]] (in the XAML)
Unable to find suitable setter or adder for property Command of type Avalonia.Controls:Avalonia.Controls.Button for argument System.Runtime:System.String, available setter parameter lists are: Avalonia.UnsetValueType Avalonia.Data.IBinding System.Windows.Input.ICommand (also in the XAML)
What could I be doing wrong in hooking up this event handler?