【问题标题】:How to get all children of a parent control in Xamarin?如何在 Xamarin 中获取父控件的所有子控件?
【发布时间】:2021-12-23 11:32:47
【问题描述】:

我正在寻找一个代码示例,如何在 Xamarin.Forms 中获取父控件的所有子控件。

【问题讨论】:

  • 使用Children属性

标签: c# .net xamarin


【解决方案1】:

是的,您可以尝试使用控件的Children 属性。

例如,有一个网格,我们可以这样访问它的Children

        var children = grid.Children;

        foreach(View child in children){
            if (child is Entry) {
                string value = ((Entry)child).Text;

                System.Diagnostics.Debug.WriteLine("one value is = " +  value);                
            }
        }

【讨论】:

    猜你喜欢
    • 2012-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多