I created an asp.net web api. It works superbly, tested with postman. I would like to display the users on the wpf datagrid. The code is as follows:
public partial class ListUsers : Page
{
public ListUsers()
{
InitializeComponent();
GetData();
}
public void GetData()
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:1234/");
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync("api/users").Result;
if (response.IsSuccessStatusCode)
{
var users = response.Content.ReadAsAsync<IEnumerable<Users>>().Result;
UserGrid.ItemsSource = users;
}
else
{
MessageBox.Show("Error Code" + response.StatusCode + " : Message - " + response.ReasonPhrase);
}
}
}
But unfortunately they appear very slowly on the data. For a moment the frost off the application. How to accelerate?
Sorry for the bad english.