I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
As we all know the wpf listview is inherited class of listbox and have almost all the properties of listbox. We have learnt listbox binding with string list in our earlier post. In this article we bind the listview with the same string list.
Just place a wpf listview having only name property, because we have to access that wpf listview in our code behind file. We can also use height and width property of the listview, if the data items are of lengthy string.
Now use the same list of string as in previous post i.e.
Now look out the last statement, it will set the item source of the wpf listview as this string list. When we run the project it will show a listview with four items:
To get selected item the same procedure will follow as in listview bind with grid resource.
Just place a wpf listview having only name property, because we have to access that wpf listview in our code behind file. We can also use height and width property of the listview, if the data items are of lengthy string.
<ListView>
<ListView.Name>listView</ListView.Name>
</ListView>
<ListView.Name>listView</ListView.Name>
</ListView>
Now use the same list of string as in previous post i.e.
List<string> strList = new List<string>();
strList.Add("London");
strList.Add("Italy");
strList.Add("California");
strList.Add("France");
listView.ItemsSource = strList;
strList.Add("London");
strList.Add("Italy");
strList.Add("California");
strList.Add("France");
listView.ItemsSource = strList;
Now look out the last statement, it will set the item source of the wpf listview as this string list. When we run the project it will show a listview with four items:
To get selected item the same procedure will follow as in listview bind with grid resource.
Comments
Post a Comment