Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Phone 7 XML populate to List Box error
    primarykey
    data
    text
    <p>I am try to do an application which loads a remote XML and populates it to the List box. I followed this tutorial and made half way through. When I have the twitter feed url I am able to populate the content to the phone. But when I try my XML it does not show up on the screen</p> <p>During this line "System.Diagnostics.Debug.WriteLine(coupon);" I am getting the XML that I am expecting. So I am sure that up to the above code everything works fine.</p> <p>My Code </p> <pre><code>void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error != null) { System.Diagnostics.Debug.WriteLine("Error: "+e); } DeviceBroker dB = new DeviceBroker(); XElement coupon = XElement.Parse(e.Result); System.Diagnostics.Debug.WriteLine(coupon); MainListBox.ItemsSource = from query in coupon.Descendants("cs") select new ViewModels.LoadCoupon() { CouponName = (string)query.Element("c").Element("t").Value, //MerchantImage = dB.getBaseUri() + "images/merchant/" + (string)query.Element("ms").Element("m").Element("id") MerchantImage = dB.getBaseUri() + "images/merchant/" + (string)query.Element("c").Element("mId") + ".png" }; } &lt;d&gt; &lt;ms&gt; &lt;m id="9921" n="The Book Company" /&gt; &lt;m id="6333" n="Earth Rental" /&gt; &lt;m id="6329" n="The Organic Baker" /&gt; &lt;m id="6331" n="News Stand" /&gt; &lt;m id="6327" n="The Jam Company" /&gt; &lt;m id="6325" n="The Fruit Company" /&gt; &lt;/ms&gt; &lt;cs&gt; &lt;c id="14533" mId="9921" t="50% Off Any Book Purchase"&gt; &lt;ls&gt; &lt;l id="40145" lng="-0.0724" lat="51.5024" d="4.97" dim="45.91" intX="" intY="" intL="" /&gt; &lt;/ls&gt; &lt;cats&gt; &lt;cat id="41" /&gt; &lt;cat id="43" /&gt; &lt;/cats&gt; &lt;as /&gt; &lt;/c&gt; &lt;/cs&gt; &lt;/d&gt; </code></pre> <p>As you can see from my code I am trying to get the d->cs->c->t and d->cs->c->mId elements. I am getting NullReferenceException was unhandeled error. If I take .Value out of the code, I am not getting any error at the same time I am not getting anything on the screen as well. Can anyone please shred some light on it? Please let me know if you need any more info.</p> <p>My XAML Looks something like this.</p> <pre><code>&lt;Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"&gt; &lt;ListBox x:Name="MainListBox"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Orientation="Horizontal" Height="132"&gt; &lt;Image Source="{Binding MerchantImage}" Height="73" Width="73" VerticalAlignment="Top" Margin="0,10,8,0"/&gt; &lt;StackPanel Width="370"&gt; &lt;TextBlock Text="{Binding CouponName}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/&gt; &lt;/StackPanel&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; &lt;/Grid&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload