C# 用当前和未来三天的XML值填充列表框?
可能重复:C# 用当前和未来三天的XML值填充列表框?,c#,xml,linq,windows-phone-7,linq-to-xml,C#,Xml,Linq,Windows Phone 7,Linq To Xml,可能重复: 我之前问了一些问题,多亏了stackoverflow的出色帮助,我解决了很多主要问题。谢谢大家!! 如果我的问题很愚蠢的话,我非常抱歉,但在stackoverflow提问之前,我已经尽可能多地用谷歌搜索了 我也有一个工作页面,在那里我可以得到具体的祈祷时间和填充文本块。 请参阅此链接和我的带解决方案的标记问题。在这里,我在类和var查询中使用public timespan: 我仍在开发穆斯林祈祷时间应用程序,希望在列表框中填入今天+未来3天的祈祷时间 DateTime m
我之前问了一些问题,多亏了stackoverflow的出色帮助,我解决了很多主要问题。谢谢大家!! 如果我的问题很愚蠢的话,我非常抱歉,但在stackoverflow提问之前,我已经尽可能多地用谷歌搜索了 我也有一个工作页面,在那里我可以得到具体的祈祷时间和填充文本块。 请参阅此链接和我的带解决方案的标记问题。在这里,我在类和var查询中使用public timespan: 我仍在开发穆斯林祈祷时间应用程序,希望在列表框中填入今天+未来3天的祈祷时间
DateTime myDay = DateTime.Now;
XDocument loadedCustomData = XDocument.Load("WimPrayerTime.xml");
var filteredData = from c in loadedCustomData.Descendants("PrayerTime")
where c.Attribute("Day").Value == myDay.Day.ToString()
&& c.Attribute("Month").Value == myDay.Month.ToString()
select new PrayerTime()
{
Fajr = c.Attribute("Fajr").Value,
Soloppgang = c.Attribute("Soloppgang").Value,
Zohr = c.Attribute("Zohr").Value,
};
listBox1.ItemsSource = filteredData;
我的班级是:
public class Prayertime
{
public string Fajr { get; set; }
public string Sunrise { get; set; }
public string Zohr { get; set; }
}
我的本地XML文件(始终包含在应用程序中)
或者我应该每天问一个问题,
DateTime NextDay=DateTime.Now.AddDays(1)
等等?如何用三个或四个不同的查询填充相同的列表框?
我可以重复一下吗:
listBox1.ItemsSource = filteredData1;
listBox1.ItemsSource = filteredData2;
listBox1.ItemsSource = filteredData3;
还有,当月份发生变化时该怎么办?例如,如果日期为30,月份为4,则第二天的值为1,月份的值为5
最后但并非最不重要。。显示信息时,我希望列表框以如下方式显示:
Monday 30.04.2012
Fajr 07:00
Sunrise 09:00
Zuhr 14:00
Tuesday 01.05.2012
Fajr 07:05
Sunrise 09:10
Zuhr 14:10
其中,属性名称和值与上面的日期/日期之间有固定的间距
非常感谢所有花时间阅读的人,也非常感谢所有回答以下问题的人:)试试这个:
where int.Parse(c.Attribute("Day").Value) >= myDay.Day && int.Parse(c.Attribute("Day").Value) < (myDay.Day + 3)
其中int.Parse(c.Attribute(“Day”).Value)>=myDay.Day&&int.Parse(c.Attribute(“Day”).Value)<(myDay.Day+3)
Monday 30.04.2012
Fajr 07:00
Sunrise 09:00
Zuhr 14:00
Tuesday 01.05.2012
Fajr 07:05
Sunrise 09:10
Zuhr 14:10
where int.Parse(c.Attribute("Day").Value) >= myDay.Day && int.Parse(c.Attribute("Day").Value) < (myDay.Day + 3)