我正在尝试使用Web服务读取数据并将其显示在如下所示的成本化的lisBox上,但它不起作用."当我进行调试时,我的手机应用程序屏幕没有显示任何列表"
XAML代码:
<ListBox Height="500" HorizontalAlignment="Left"
Margin="8,47,0,0"
Name="friendsBox" VerticalAlignment="Top" Width="440">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Height="100" Width="100"
VerticalAlignment="Top" Margin="0,10,8,0"
Source="{Binding Photo}"/>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding Nom}" FontSize="28" TextWrapping="Wrap" Style="{StaticResource PhoneTextAccentStyle}"/>
<TextBlock />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
C#代码:
void friends_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
ListBoxItem areaItem = null;
StringReader stream = new StringReader(e.Result);
XmlReader reader = XmlReader.Create(stream);
string Nom = String.Empty;
string Photo = String.Empty;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == …Run Code Online (Sandbox Code Playgroud)