为什么这样工作:
XDocument dataFeed = XDocument.Parse(e.Result);
var guide = from query in dataFeed.Descendants("MaxPayne3")
select new NewGamesClass
{
GameID = (string)query.Element("ID"),
GameTitle = (string)query.Element("Title"),
GameDescription = (string)query.Element("Description"),
GameGuide = (string)query.Element("Guide")
};
if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
{
if (selectedIndex == "0")
GuidesListBox.ItemsSource = guide.Where(ngc => ngc.GameTitle.StartsWith("Feel"));
else if (selectedIndex == "1")
GuidesListBox.ItemsSource = guide.Where(ngc => ngc.GameTitle.StartsWith("Serious"));
但不是这样:
if (selectedIndex == "0")
GuidesListBox.ItemsSource = guide.Where(ngc => ngc.GameID.StartsWith("000"));
else if (selectedIndex == "1")
GuidesListBox.ItemsSource = guide.Where(ngc => ngc.GameID.StartsWith("001"));
我想使用 GameID 而不是 GameTitle。
抱歉没有 XML,对我来说太早了,哈哈
这里: https ://dl.dropbox.com/u/27136243/AchivementHunters/XML/GameList.xml
这是课程:
public class NewGamesClass
{
string gameID;
string gameTitle;
string gamedescription;
string gameImage;
string gameGuide;
string videoLink;
public string GameID
{ get { return gameID; } set { gameID = value; } }
public string GameTitle
{ get { return gameTitle; } set { gameTitle = value; } }
public string GameDescription
{ get { return gamedescription; } set { gamedescription = value; } }
public string GameImage
{ get { return gameImage; } set { gameImage = value; } }
public string GameGuide
{ get { return gameGuide; } set { gameGuide = value; } }
public string VideoLink
{ get { return videoLink; } set { videoLink = value; } }
}