0
我在这里有一个小问题,我不知道如何自己解决它。 我想要做的是,我想改变数组(名称)中每个项目的图像源。Windows Phone 8 C# - 更改foreach循环中xaml项的名称
这是我的代码看起来像现在: (在m.Source M为其中名称应该去)
private void Stars()
{
string[] LevelPick = new string[] {"Stage1Level1", "Stage1Level2", "Stage3Level3" };
foreach (string m in LevelPick)
{
string Stars = appSettings[""+m+""].ToString();
if(Stars == "0")
{
BitmapImage bm = new BitmapImage(new Uri("/Resources/Images/GeenSter.png", UriKind.RelativeOrAbsolute));
m.Source = bm; // error here
}
else
{
BitmapImage bm = new BitmapImage(new Uri("/Resources/Images/GeenSter.png", UriKind.RelativeOrAbsolute));
m.Source = bm; // same here
}
}
}
,我得到的错误是:
“串'不包含'来源'的定义。
有没有人知道如何解决这个问题? 在此先感谢!
错误消息不明确?由于'm'是'string',因此没有属性或字段被称为'Source'。你想要做什么? – 2014-11-03 15:43:10
你应该创建一个Image,这个类有一个Source属性 – thumbmunkeys 2014-11-03 15:44:26
@thumbmunkeys数组中的名字是图像: 等 –
2014-11-03 15:48:05