Search code examples
c#.net-coreavalonia

Avalonia: How to add a Control to UserControl programmatically


I can do that on Grid well with Grid.Children.Add(...) But I can't figure out how can I add a control to UserControl programmatically.


Solution

  • In order to use the Children property, your control has to implement the IPanel interface. The easiest way to achieve that is to make Panel a base class for your UserControl.