0
我想顯示web服務在wp列表框中的數據。 web服務中的數據包含3個字段以及一個圖像,並且數據必須被刷新,即當輸入新數據時,它應該首先出現。當我構建我的第一個應用程序時,我發現它有點困難。請幫忙。我的.cs代碼,直至現在如何顯示web服務在列表框中的數據
namespace KejriwalPhoneApp
{
public partial class News : PhoneApplicationPage
{
public class Newss
{
public string News_Title { get; set; }
public string News_Description { get; set; }
public string Date_Start { get; set; }
}
public class NewsList: List<Newss>
{
public NewsList()
{
}
}
public News()
{
InitializeComponent();
KejriwalService.aapSoapClient myClient = new KejriwalService.aapSoapClient();
myClient.getarvindNewsCompleted += new EventHandler<KejriwalService.getarvindNewsCompletedEventArgs>(myClient_getarvindNewsCompleted);
myClient.getarvindNewsAsync();
}
void myClient_getarvindNewsCompleted(object sender, KejriwalService.getarvindNewsCompletedEventArgs e)
{
listBox1.ItemsSource = e.Result;
}
}
}
我的數據集:
<string><NewDataSet>
<UserDetails>
<id>5</id>
<News_Title>Audit of Electricity Companies</News_Title>
<News_Description> Rejecting the contention of private power distributors, the Delhi government today ordered an audit of their finances by the government's national auditor or Comptroller and Auditor General (CAG), fulfilling yet another election promise of the Aam Aadmi Party.
&quot;We have ordered an audit of the private power distribution companies. The CAG has said it will do the audit,&quot; Chief Minister Arvind Kejriwal said. He also said Lieutenant Governor Najeeb Jung's order on the audit of the companies will go to CAG Shashi Kant Sharma tomorrow.</News_Description>
<Date_Start>2014-01-03</Date_Start>
<image_path>news.png</image_path>
在這裏,我需要顯示news_title,news_Description,DATE_START,在一個列表中的圖像應該是點擊而且會有超過1個數據
我的XAML文件是
<ListBox Name="listBox1" Margin="38,86,38,562">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=News_Title}"></TextBlock>
<TextBlock Text="{Binding Path=News_Description}"></TextBlock>
<TextBlock Text="{Binding Path=Date_Start}"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
什麼是你的代碼的問題?什麼類型是'e.Result'? – har07
使用lambda表達式遍歷結果並將它們映射到Newss數據模型的集合。然後,將您的列表框ItemsSource設置爲newss集合 – kindasimple