Browse Source
Merge pull request #12840 from abpframework/enisn/menu-item-name
Add menu item name to PageLayout
pull/12852/head
Halil İbrahim Kalkan
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
50 additions and
5 deletions
docs/en/UI/Blazor/Page-Layout.md
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageLayout.cs
@ -13,6 +13,37 @@ Title is used to render page title in the PageHeader.
}
```
## MenuItemName
Indicates current selected menu item name. Menu item name should match a unique menu item name defined using the [Navigation / Menu system ](../Blazor/Navigation-Menu.md ). In this case, it is expected from the theme to make the menu item "active" in the main menu.
```csharp
@inject PageLayout PageLayout
@code {
protected override async Task OnInitializedAsync()
{
PageLayout.MenuItemName = "MyProjectName.Products";
}
}
```
Menu item name can be set on runtime too.
```html
@inject PageLayout PageLayout
< Button Clicked = "SetCategoriesMenuAsSelected" > Change Menu< / Button >
@code {
protected void SetCategoriesMenuAsSelected()
{
PageLayout.MenuItemName = "MyProjectName.Categories";
}
}
```
> Be aware, The [Basic Theme ](../Blazor/Basic-Theme.md ) currently doesn't support the selected menu item since it is not applicable to the top menu.
## BreadCrumbs
BreadCrumbItems are used to render breadcrumbs in the PageHeader.
```csharp
@ -1,5 +1,6 @@
using System.Collections.ObjectModel ;
using System.ComponentModel ;
using System.Runtime.CompilerServices ;
using Volo.Abp.AspNetCore.Components.Web.Theming.PageToolbars ;
using Volo.Abp.BlazoriseUI ;
using Volo.Abp.DependencyInjection ;
@ -11,19 +12,32 @@ public class PageLayout : IScopedDependency, INotifyPropertyChanged
private string title ;
// TODO: Consider using this property for setting Page Title too.
public virtual string Title
{
public virtual string Title {
get = > title ;
set
{
set {
title = value ;
PropertyChanged ? . Invoke ( this , new PropertyChangedEventArgs ( nameof ( Title ) ) ) ;
OnPropertyChanged ( ) ;
}
}
private string menuItemName ;
public string MenuItemName {
get = > menuItemName ;
set {
menuItemName = value ;
OnPropertyChanged ( ) ;
}
}
public virtual ObservableCollection < BreadcrumbItem > BreadcrumbItems { get ; set ; } = new ( ) ;
public virtual ObservableCollection < PageToolbarItem > ToolbarItems { get ; set ; } = new ( ) ;
public event PropertyChangedEventHandler PropertyChanged ;
protected void OnPropertyChanged ( [ CallerMemberName ] string propertyName = null )
{
PropertyChanged ? . Invoke ( this , new PropertyChangedEventArgs ( propertyName ) ) ;
}
}