c# - 将列表传递给 RootElement c# 中的部分

标签 c# ios list xamarin sections

我正在向 RootElement 的一部分添加某些值,如下所示:-

NavigationRoot = new RootElement("Menu"){ //Here we create the root of the elements
     new Section("Pages"){
      new StringElement ("Feed"),
      new StringElement ("Messages"),
      new StringElement ("Nearby"),
      new StringElement ("Events"),
      new StringElement ("Friends"),

     },

现在,StringElements 是硬编码的。我想将我从 API 调用中获取的字符串列表传递给该部分。该列表将是动态的。如何传递此列表来创建具有列表中字符串值的项目部分?

感谢任何帮助。

最佳答案

如果你有一个字符串数组,你可以使用 Linq 试试这个:-

from page in myStringArray select new StringElement (page) as Element; 

关于c# - 将列表传递给 RootElement c# 中的部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34651991/

相关文章:

ios - Swift - 如何在调用 removeFromSuperview() 后得到通知?

python - 在 python 中跳过初始列表项(或基于项目的分区列表)的更紧凑的方法是什么?

Python 全局列表

c# - 使用 mvc6 网格时无法将显示格式设置为小数点后两位

JavaScript 对象已设置,但访问时为 null

ios - 如何在swift中取消初始化类对象?

ios - SceneKit 对象在它们的边界框而不是沿着网格发生碰撞

c# - 函数主机未运行

c# - SQLite.SQLite3 : Exception System. DllNotFoundException

python - 列表推导式提示