Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON Deserialize JSON.Net C#
    primarykey
    data
    text
    <p><strong>UPDATE:</strong></p> <p>I have a <strong>listbox</strong> which has to be filled with JSON data received from webservice. I successfully retrieve the JSON data and the listbox is filled with listitems but each listitem does not show the value of the JSON data parsed and shows it blank.</p> <p>Code follows:</p> <pre><code> private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { WebClient webClient = new WebClient(); webClient.DownloadStringCompleted += webClient_DownloadStringCompleted; webClient.DownloadStringAsync(new Uri("http://foo.com/w.php")); } void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { string json = e.Result; if (!string.IsNullOrEmpty(json)) { PortfolioResult results = JsonConvert.DeserializeObject&lt;PortfolioResult&gt;(json); lstPortfolio.ItemsSource = results.results; } } public class Portfolios { public string PortfolioID { get; set; } public string Title { get; set; } public string Image { get; set; } public string Comment { get; set; } public string IsEnable { get; set; } public string CountryName { get; set; } public string DateAdded { get; set; } public string DateUpdated { get; set; } } public class PortfolioResult { public List&lt;Portfolios&gt; results { get; set; } } </code></pre> <p>The XAML:</p> <pre><code> &lt;ListBox Name="lstPortfolio" Foreground="Black" Margin="12,76,12,12" Grid.Row="1" Width="456" Height="680"&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Height="auto" Width="456" VerticalAlignment="Top" Orientation="Horizontal"&gt; &lt;StackPanel Orientation="Vertical" Height="145" Width="460"&gt; &lt;StackPanel Orientation="Horizontal" Height="35"&gt; &lt;TextBlock Width="150" TextWrapping="Wrap" Foreground="#FF527104" Text="ID:" FontSize="22" Height="40"/&gt; &lt;TextBlock Width="250" TextWrapping="Wrap" Foreground="#FF527104" Text="{Binding Path=PortfolioID}" FontSize="20" Height="40"/&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Horizontal" Height="35"&gt; &lt;TextBlock Width="150" TextWrapping="Wrap" Foreground="#FF527104" Text="Name:" FontSize="22" Height="40"/&gt; &lt;TextBlock Width="250" TextWrapping="Wrap" Foreground="#FF527104" Text="{Binding Path=Title}" FontSize="20" Height="40"/&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Horizontal" Height="35"&gt; &lt;TextBlock Width="150" TextWrapping="Wrap" Foreground="#FF527104" Text="Details:" FontSize="22" Height="40"/&gt; &lt;TextBlock Width="250" TextWrapping="Wrap" Foreground="#FF527104" Text="{Binding Path=Comment}" FontSize="20" Height="40"/&gt; &lt;/StackPanel&gt; &lt;StackPanel Orientation="Horizontal" Height="35"&gt; &lt;TextBlock Width="150" TextWrapping="Wrap" Foreground="#FF527104" Text="Date:" FontSize="22" Height="40"/&gt; &lt;TextBlock Width="250" TextWrapping="Wrap" Foreground="#FF527104" Text="{Binding Path=DateUpdated}" FontSize="20" Height="40"/&gt; &lt;/StackPanel&gt; &lt;Border BorderBrush="#FF527104" BorderThickness="0,0,0,1" Height="1" VerticalAlignment="Top"/&gt; &lt;/StackPanel&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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