I have ObservableCollection<User> UsersList
. I need Binding this collection to my TreeView. How i can do this on AvaloniaUI?
My class User:
public class User
{
public int? Id { get; set; }
public string? Name { get; set; }
public string? Username { get; set; }
public string? Email { get; set; }
public Address? Address { get; set; }
public string? Phone { get; set; }
public string? Website { get; set; }
public Company? Company { get; set; }
}
public class Company
{
public string? Name { get; set; }
public string? CatchPhrase { get; set; }
public string? Bs { get; set; }
}
public class Address
{
public string? Street { get; set; }
public string? Suite { get; set; }
public string? City { get; set; }
public string? Zipcode { get; set; }
public Geo? Geo { get; set; }
}
public class Geo
{
public string? Lat { get; set; }
public string? Lng { get; set; }
}
I get my UsersList collection from httpclienе and my collection have 10 elements.
My XAML:
<TreeView ItemsSource="{Binding UsersList}">
</TreeView>
Result: enter image description here
How i must bind collection to treeview?
New contributor
Кирилл is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.