【问题标题】:Avalonia: How to add a Control to UserControl programmaticallyAvalonia:如何以编程方式向 UserControl 添加控件
【发布时间】:2021-12-11 07:29:57
【问题描述】:

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

【问题讨论】:

    标签: c# .net-core avalonia


    【解决方案1】:

    为了使用Children 属性,您的控件必须实现IPanel 接口。实现这一目标的最简单方法是将Panel 设为UserControl 的基类。

    【讨论】:

    • 我在 UserControl 中添加了一个面板并使用它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-27
    • 1970-01-01
    • 1970-01-01
    • 2018-11-02
    • 1970-01-01
    相关资源
    最近更新 更多