【发布时间】:2021-12-23 11:32:47
【问题描述】:
我正在寻找一个代码示例,如何在 Xamarin.Forms 中获取父控件的所有子控件。
【问题讨论】:
-
使用
Children属性
我正在寻找一个代码示例,如何在 Xamarin.Forms 中获取父控件的所有子控件。
【问题讨论】:
Children属性
是的,您可以尝试使用控件的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);
}
}
【讨论】: