【发布时间】:2015-10-06 10:08:35
【问题描述】:
我尝试在 WPF 应用程序中循环我的食物对象的名称。
我想要以下食物元素的名称:food0、food1、foot2 ...
for (int i = 0; i < foods.Count; i++)
{
System.Windows.UIElement foodelement = "food" + i; // ERROR here
Canvas.SetLeft(foodelement, foods[i].Position.X);
}
我得到错误:
Cannot implicitly convert type string to System.Windows.UIElement
【问题讨论】:
标签: c# wpf xaml loops variables