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 }); }
When a window is added to WPF project then grid is added by default having zero children. It is most often used panel in compare to dock panel, stack panel and other panels. Grid provides no of rows and columns which enables you to arrange the elements without wrapping, stacking. It is like table in programming where we can add no of rows and columns as required.
Grid cells can be either left empty or multiple elements can also be placed in a single cell. Other panels like stack panel or wrap panel can also be used in the grid. Resizing the rows or columns can also be done using Grid Splitter. All this can be also performed by using code behind file.
Grid provides many more in-built functions like sharing width of a column, resizing cells, adding controls to grid and many more.
Canvas panel
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
</Grid>
We have to specify the position of each child using either Grid.Row or Grid.Column property of each child in this grid. If we not then it will place all the children in first cell by default.<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
</Grid>
Grid cells can be either left empty or multiple elements can also be placed in a single cell. Other panels like stack panel or wrap panel can also be used in the grid. Resizing the rows or columns can also be done using Grid Splitter. All this can be also performed by using code behind file.
Grid provides many more in-built functions like sharing width of a column, resizing cells, adding controls to grid and many more.
Canvas panel
Comments
Post a Comment