需要帮助在组中的.xaml上显示分组的xml数据

时间:2012-01-06 20:28:52

标签: c# xml windows-phone-7

这是基本的xml ..

<events>
 <eventday>
  <eventdate>Date of events group 1</eventdate>
   <eventsonday>
    <eventitem>
     <eventtime>Time of event 1</eventtime>
     <eventtitle>Title of event 1</eventtitle>
     <eventlocation>Location of event 1</eventlocation>
    </eventitem>
    <eventitem>
     <eventtime>Time of event 2</eventtime>
     <eventtitle>Title of event 2</eventtitle>
     <eventlocation>Location of event 2</eventlocation>
    </eventitem>
   </eventsonday>
  </eventday>
  <eventday>
  <eventdate>Date of events group 2</eventdate>
   <eventsonday>
    <eventitem>
     <eventtime>Time of event 3</eventtime>
     <eventtitle>Title of event 3</eventtitle>
     <eventlocation>Location of event 3</eventlocation>
    </eventitem>
    <eventitem>
     <eventtime>Time of event 4</eventtime>
     <eventtitle>Title of event 4</eventtitle>
     <eventlocation>Location of event 4</eventlocation>
    </eventitem>
   </eventsonday>
  </eventday>
</event>

我想以与显示Windows手机日历(议程视图)相同的方式显示数据。

2012年1月5日星期四

time of event 1
title of event 1
location of event 1

time of event 2
title of event 2
location of event 2

2012年1月6日星期五

time of event 3
title of event 3
location of event 3

time of event 4
title of event 4
location of event 4

我认为我没有正确解析数据,或者正确设置了.xaml。我认为需要将其设置为绑定Listbox中的堆栈面板中的数据,但是&lt; eventdate&gt;团体名称令我困惑。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

首先,创建表示xml文件的类层次结构,并将xml数据解析为它。

对于用户界面,请使用LongListSelector中的Silverlight Toolkit控件。 LongListCollection可帮助您按日期对事件进行分组。

用法:

 var list = new LongListCollection<Event, string>(Events, x => x.Date.ToLongDateString());