Tabbed display mode
Lagoon can display pages in simple page mode or in application tabbed mode. Tabbed mode is enabled in App.razor with IsTabbed="true".
Enable tabbed mode
<LgApp DefaultLayout="typeof(MainLayout)" IsTabbed="true" ShowHeader="true" ShowSidebar="false">
<StartupTabs>
<LgStartupTab Link="Demo.Client.Pages.Index.Link()" />
</StartupTabs>
<ChildContent>
<MenuConfiguration />
</ChildContent>
</LgApp>
Home page
The home page is defined by its root route.
@inherits LgPage
[Route(ROUTE)]
public partial class HomePage : LgPage
{
private const string ROUTE = "/";
public static LgPageLink Link()
{
return LgPageLink.Create(ROUTE, "#homeTitle", IconNames.Home);
}
}
Tab title and icon
For a Lagoon page, centralize the title and icon in the static Link() method.
[Route(ROUTE)]
public partial class CounterPage : LgPage
{
private const string ROUTE = "counter";
public static LgPageLink Link()
{
return LgPageLink.Create(ROUTE, "#menuCounter", IconNames.All.CalculatorFill);
}
}
The tab then retrieves the translated title and icon via the typed link.
Open a tab
A link to a route corresponding to an existing page automatically opens the associated tab. In code, use Lagoon navigation rather than a hard-coded URL.
public partial class MyComponent : LgComponentBase
{
private void OpenCounter()
{
// Opens the target page in the application's current navigation mode.
App.NavigateTo(CounterPage.Link().Uri);
}
}
Tabs open at startup
StartupTabs lets you declare pages that open automatically at startup.
<LgApp DefaultLayout="typeof(MainLayout)" IsTabbed="true" ShowHeader="true" ShowSidebar="false">
<StartupTabs>
<LgStartupTab Link="Demo.Client.Pages.Index.Link()" Default="true" />
<LgStartupTab Link="DashboardPage.Link()" Closable="true" PolicyVisible="DashboardReader" />
</StartupTabs>
<ChildContent>
<MenuConfiguration />
</ChildContent>
</LgApp>
Reload the active tab
The reload behavior when clicking the active tab is controlled by TabReloadDisabled in OnConfigureBehavior.
public class Main : LgCustomApplication
{
protected override void OnConfigureBehavior(ApplicationBehavior app)
{
// Disables content reload when the user clicks the active tab again.
app.TabReloadDisabled = true;
}
}
Save open tabs
By default, tabs are not saved. TabSavingMethod enables:
| Value | Effect |
|---|---|
TabSavingMethod.None | Does not save tabs. |
TabSavingMethod.Local | Saves tabs in the browser via IndexedDB. |
TabSavingMethod.Remote | Saves tabs in the server database. |
public class Main : LgCustomApplication
{
protected override void OnConfigureBehavior(ApplicationBehavior app)
{
// Restores tabs after refresh or reconnection.
app.TabSavingMethod = TabSavingMethod.Remote;
}
}
Close all tabs
TryCloseAllTabs() attempts to close all open tabs.
@inherits LgComponentBase
<LgButton Text="#closeAllTabs" OnClick="CloseAllTabsAsync" />
public partial class TabsActions : LgComponentBase
{
private Task CloseAllTabsAsync(ActionEventArgs args)
{
// Tabs that refuse to close can display their confirmation dialog.
App.TryCloseAllTabs();
return Task.CompletedTask;
}
}