question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to find suitable setter or adder for property Click

See original GitHub issue

I’m unable to set “Click” event for Button in XAML. Adding “Click” attribute in XAML throws error during compilation (no matter if method exist or not in cs file): “Avalonia error XAMLIL: Unable to find suitable setter or adder for property Click of type Avalonia.Controls:Avalonia.Controls.Button for argument System.Runtime:System.String, available setter parameter lists are:”

Here is MainWindow.xaml:

<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="MMHelper.MainWindow"
        Title="MMHelper">
    <Button Click="testClick" Content="Test" />
</Window>

I’ve looked into issues and found similar issue but I seems it was fixed. I’m using .Net Core 3.1 on Arch Linux, Avalonia version is 0.9.2.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Jerkovizcommented, Jun 15, 2022

Hi. I have similar problem. I am trying to add event SelectionChanged to drop box, but I get this error. Also getting same error with PointerPressed event in data grid, but LoadingRow works. So theese are events from documentation. Am I missing something? I’m using Avalonia 0.10.14 on Windows and .NET6.

<ComboBox Name="ComboBox" Width="100" Height="28" Margin="15,21,0,0" Items="{Binding SerialCards}" SelectedItem="{Binding Path=SelectedCard, Mode=TwoWay}" SelectionChanged="_DropDownClosed"/>

<DataGrid MaxHeight="300" Name="InvoicesGrid" Items="{Binding SdcImportedInvoices}" AutoGenerateColumns="False" LoadingRow="dataGrid_LoadingRows" IsReadOnly="True" PointerPressed="_OnRowClick">

0reactions
bsvabiccommented, Jun 28, 2022

Hello… I had similar problem, also, and I resolved it on a way that I’m used propper parameter in a given event method. For example, if we want use GotFocus we can use method such as:

`private void Handler(object sender, GotFocusEventArgs e)
        {
            
        }`

If we want use LostFocus we can use it such as:

`private void Handler2(object sender, RoutedEventArgs e)
        {
            
        }`

If we want use TextInput event we can use it such as:

`private void Handler3(object sender, TextInputEventArgs e)
        {
            
        }`

Where Handler, Handler2 and Handler3 are names of given event from xaml. You can see documentation, for example for textbox control: http://reference.avaloniaui.net/api/Avalonia.Controls/TextBox/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Button will not work, unable to find suitable setter or getter
'Unable to find suitable setter or adder for property Click of type Avalonia.Controls:Avalonia.Controls.Button for argument Avalonia.
Read more >
Unable to find a setter that allows multiple assignments to the ...
Unable to find a setter that allows multiple assignments to the property Content of type Avalonia.Controls:Avalonia.Controls.ContentControl.
Read more >
XAMLIL: Unable to find suitable setter or adder for property ...
Hello! Recently, I update Avalonia on my project to nightly build (now preview build Avalonia 0.9.0-preview3) and some problems has appeared ...
Read more >
RoutedEventArgs Class - Typedescriptor
On This Page. Constructors; Properties; Assemblies; Issues ... Unable to find suitable setter or adder for property Click of type Avalonia.Controls #3898.
Read more >
Binding to Commands
Controls that carry out an action, such as Button have a Command property which can be bound to an ICommand . When the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found