EmreGeer-4824 avatar image
0 Votes"
EmreGeer-4824 asked EmreGeer-4824 commented

How to get data from API to wpf mvvm

I have Wpf application. I need to get data from api to wpf. I have treeview and i wanna put the data to treeview`ublic async void GetAllEmployee()
using (HttpClient client = new HttpClient())
HttpResponseMessage response = await client.GetAsync($"{conURL}/GetEmployee");

                 if (response.IsSuccessStatusCode)
                     MessageBox.Show("Value getted");

                 IList<EmployeeModel> ls =
                     await response.Content.ReadAsAsync<IList<EmployeeModel>>();
             catch (Exception ex)
                 MessageBox.Show(ex.Message + "May server not running");

This is how i tried to get data but i cannot use in viewmodel.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,@EmreGeer-4824 . Welcome Microsoft Q&A.
You could try to see if the solutions here work for you. Or is it possible to share a minimal code that reproduces the problem?

1 Vote 1 ·

Thank you very much for your answer. I tried solution in that link which you send me. But still i couldn't handle it. Here is git link
If you will have time you can check it TestProjectUI. I messed up with this project. I do not know how to solve it)

0 Votes 0 ·

0 Answers