Error: "Can not implicitly convert type" void "to" EventHandler "

0

I was trying to make a button that passed the information of an entry and a StackLayout and this error appears to me:

    public MainPage()
    {

        InitializeComponent();

        Entry entry = new Entry() { Keyboard = Keyboard.Numeric };

        Button button = new Button();

        StackLayout stack = new StackLayout()
        {
            Children =
            {
                button,
                entry
            }
        };

        button.Clicked += Button_Clicked(stack, entry); //O erro aparece nessa linha
    }
    private async void Button_Clicked(StackLayout stack, Entry entry)
    {
        int qtd_in = Int16.Parse(entry.Text);

        for (int i = 0; i < qtd_in; i++)
        {
            Entry entradas = new Entry();
            stack.Children.Add(entradas);
        }//O código deveria criar novas entradas de acordo com a primeira entry
    }
    
asked by anonymous 25.10.2018 / 14:57

1 answer

1

The description of your error already says it all, the clicked expects a return event handler and your method is of type void, the correct way to call your method would look something like this:

button.Clicked += (object sender, EventArgs e) =>
{
 Button_Clicked(stack, entry);
}
    
25.10.2018 / 16:19