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 }); }
- Add a GridView control to a parent container using XAML code editor with name attribute.
</GridView>
To assign a name to the grid view, set the x:Name attribute to a string value. To refer to a control in code, it must have a name. Otherwise, a name is not required.
2. Add items to the grid view by populating the Items collection or by binding the ItemsSource property to a data source.
<x:String> name </x:String>
<x:String> City </x:String>
</GridView>
Start Screen
Apply II method in code file
1. Create a List of String Items and bind with GridView control in main file constructor.
public MainPage()
{
this.InitializeComponent();
List<String> itemcoll = new List<String>();
itemcoll.Add("Apple");
itemcoll.Add("Mango");
GridView1.ItemsSource = itemcoll;
}
Comments
Post a Comment