Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Display data in textblock after JSON Parsing
    primarykey
    data
    text
    <p>I am trying to parse some json data in my Windows application. I had written some codes for the same. The code is error free but no data appears in my textblock. Here is my XAML</p> <pre><code>&lt;TextBlock Name="acc1" Margin="180, 60, 0, 0" Text="{Binding Accnumber1}" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Left" FontFamily="Segoe UI" FontSize="22" /&gt; &lt;TextBlock Name="bal1" Margin="180, 90,0, 0" Text="{Binding Availablebalance}" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Left" FontFamily="Segoe UI" FontSize="22" /&gt; &lt;TextBlock Name="acc2" Margin="180, 140, 0, 0" Text="{Binding Accnumber2}" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Left" FontFamily="Segoe UI" FontSize="22" /&gt; &lt;TextBlock Name="bal2" Margin="180, 170, 0, 0" Text="{Binding Availablebalance}" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Left" FontFamily="Segoe UI" FontSize="22" /&gt; </code></pre> <p>and this my class file</p> <pre><code>public MainPage() { InitializeComponent(); CheckForAnimation(); BackKeyPress += OnBackKeyPressed; WebClient webClient = new WebClient(); webClient.DownloadStringCompleted += webClient_DownloadStringCompleted; ProgressBarRequest.Visibility = System.Windows.Visibility.Visible; webClient.DownloadStringAsync(new Uri("http://mobimybank.appspot.com/loginresponse.json")); } void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { if (!string.IsNullOrEmpty(e.Result)) { var root1 = JsonConvert.DeserializeObject&lt;RootObject&gt;(e.Result); this.DataContext = root1; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { ProgressBarRequest.Visibility = System.Windows.Visibility.Collapsed; } } </code></pre> <p>This is the RootObject class file</p> <pre><code>public class Mybank { public string status { get; set; } } public class Account { public string Accnumber1 { get; set; } public string Availablebalance { get; set; } public string Accnumber2 { get; set; } } public class Accounts { public List&lt;Account&gt; Account { get; set; } } public class Loginresponse { public Mybank { get; set; } public Accounts { get; set; } } public class RootObject { public Loginresponse loginresponse { get; set; } } </code></pre> <p>When i added a watcher at data context it tells me the data is been fetched. But the data is not displayed in above given textblocks. please tell me the area i am doing things wrong or the correct method to display the data.</p>
    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.
 

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