简体   繁体   English

Avalonia:如何以编程方式向 UserControl 添加控件

[英]Avalonia: How to add a Control to UserControl programmatically

我可以使用Grid.Children.Add(...)在 Grid 上很好地做到这一点,但我不知道如何以编程方式向 UserControl 添加控件。

In order to use the Children property, your control has to implement the IPanel interface.为了使用Children属性,您的控件必须实现IPanel接口。 The easiest way to achieve that is to make Panel a base class for your UserControl .实现这一目标的最简单方法是使Panel成为UserControl的基类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM