diff --git a/docs/en/UI/Blazor/Page-Layout.md b/docs/en/UI/Blazor/Page-Layout.md
index 61d91d66af..49ed1659f4 100644
--- a/docs/en/UI/Blazor/Page-Layout.md
+++ b/docs/en/UI/Blazor/Page-Layout.md
@@ -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
+
+
+
+@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
diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageLayout.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageLayout.cs
index 618445bd83..3edbb9dc45 100644
--- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageLayout.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Layout/PageLayout.cs
@@ -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 BreadcrumbItems { get; set; } = new();
public virtual ObservableCollection ToolbarItems { get; set; } = new();
public event PropertyChangedEventHandler PropertyChanged;
+
+ protected void OnPropertyChanged([CallerMemberName]string propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
}
\ No newline at end of file