Search code examples
c#wpfwpf-controls

how to display json data in wpf (c#)


i have a wpf im working on I've never done wpf but I cant seem to get the json data from an API show as its just saying null, my code is but its just saying null in winforms I usually put this in the form load but wpf user control doesn't have a form load I tried it in the

public UserControl1(){

}

but that didn't work as its returning null any suggestions.

var wc = new WebClient();
var users = "API link";
label.Content = users;

Solution

  • What if you do all that after the InitializeComponent(); call in your constructor ?

    Once the label variable is set, then you can use it.