I created the button using XAML, and i want that this button will make a new one, how to create and display new button using only code?
I guessed to this
var bt = new Button();
bt.Height = 100;
bt.Name = "QWE";
But I IDK what to do next.
I created the button using XAML, and i want that this button will make a new one, how to create and display new button using only code?
I guessed to this
var bt = new Button();
bt.Height = 100;
bt.Name = "QWE";
But I IDK what to do next.
You need to add your button to the panel. In Avalonia, different kinds of Panels are used to host one or more controls with different layout rules (stack, grid, wrap...).
Let's say if you had your XAML like this:
Grid would be a parent Panel here.
The same XAML can be rewritten to C# code in a similar way:
Or, alternatively, if you need to mix both XAML and C#, you can assign a Name to the Grid:
And then add button to it from the C# code:
Hope it helps.