Skip to content

Commit 2658142

Browse files
Merge pull request #4 from DevExpress-Examples/doc_review
Doc review
2 parents d814f7e + 0ea84d0 commit 2658142

File tree

11 files changed

+108
-30
lines changed

11 files changed

+108
-30
lines changed

CS/DxBlazorApplication1/Components/Layout/MainLayout.razor

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
private RenderFragment drawerHeader => @<div class="navigation-drawer-header">
3030
<img class="logo" src="images/logo.svg" alt="DevExpress logo" />
3131
<NavLink href="@UrlGenerator.GetUrl(new Uri(NavigationManager.Uri).LocalPath, !ToggledSidebar)">
32-
<DxButton RenderStyle="@ButtonRenderStyle.Light" RenderStyleMode="@ButtonRenderStyleMode.Text" CssClass="menu-button-nav" IconCssClass="@(ToggledSidebar ? "icon icon-close" : "icon icon-menu")"></DxButton>
3332
</NavLink>
3433
</div>;
3534

CS/DxBlazorApplication1/Components/Layout/NavMenu.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Items>
44
<DxMenuItem Name="Counter" Text="Counter" CssClass="menu-item" IconCssClass="icon counter-icon"></DxMenuItem>
55
<DxMenuItem Name="Weather" Text="Weather" CssClass="menu-item" IconCssClass="icon weather-icon"></DxMenuItem>
6-
<DxMenuItem Name="Forms" Text="Forms" CssClass="menu-item" IconCssClass="icon weather-icon"></DxMenuItem>
6+
<DxMenuItem Name="Form" Text="Form" CssClass="menu-item" IconCssClass="icon form-icon"></DxMenuItem>
77
</Items>
88
</DxMenu>
99
</div>

CS/DxBlazorApplication1/Components/Layout/NavMenu.razor.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
background-image: url("images/weather.svg");
4949
}
5050

51+
::deep .form-icon {
52+
background-image: url("images/form.svg");
53+
}
54+
5155
::deep .counter-icon {
5256
background-image: url("images/counter.svg");
5357
}

CS/DxBlazorApplication1/Components/Pages/Counter.razor

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@page "/counter"
22
@rendermode InteractiveServer
3-
<PageTitle>Counter</PageTitle>
43

54
<h1>Counter</h1>
65

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@page "/forms"
1+
@page "/form"
22

33
<style>
44
.my-form{
@@ -11,16 +11,17 @@
1111
<DxTextBox></DxTextBox>
1212
</DxFormLayoutItem>
1313
<DxFormLayoutItem Caption="Age">
14-
<DxSpinEdit T="int"></DxSpinEdit>
15-
</DxFormLayoutItem>
16-
<DxFormLayoutItem Caption="DOB">
17-
<DxDateEdit T="DateTime"></DxDateEdit>
14+
<DxSpinEdit T="int" MinValue="0"></DxSpinEdit>
1815
</DxFormLayoutItem>
1916
<DxFormLayoutItem Caption="Hobbies">
2017
<DxTagBox TData="string" TValue="string"
2118
Data="@(new List<string>(){"Swimming", "Hiking", "Chess"})"></DxTagBox>
2219
</DxFormLayoutItem>
23-
<DxFormLayoutItem ColSpanMd="12" Caption="Photo">
24-
<DxFileInput></DxFileInput>
20+
<DxFormLayoutItem BeginRow="true">
21+
<DxFileInput SelectButtonText="Add a Photo"></DxFileInput>
2522
</DxFormLayoutItem>
2623
</DxFormLayout>
24+
25+
@code {
26+
DateTime Today = DateTime.Today;
27+
}

CS/DxBlazorApplication1/Components/Pages/Index.razor

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
@inject IJSRuntime JS
55
@inject MDIStateHelper StateHelper
66

7+
<PageTitle>Multi-Tab Interface</PageTitle>
8+
79
<div @ref=divContainer>
810
<DxTabs @ref=tabs
911
@bind-ActiveTabIndex=activeTabIndex
@@ -12,13 +14,19 @@
1214
TabClosing="OnTabClosing"
1315
RenderMode="TabsRenderMode.AllTabs">
1416
<DxTabPage CssClass="counter-tab" AllowClose="true" VisibleIndex="@collection.GetVisibleIndexByTabText("Counter")" Visible="@collection.GetVisibleByTabText("Counter")" Text="Counter">
15-
<Counter></Counter>
17+
<div class="tab-body">
18+
<Counter />
19+
</div>
1620
</DxTabPage>
1721
<DxTabPage CssClass="weather-tab" AllowClose="true" VisibleIndex="@collection.GetVisibleIndexByTabText("Weather")" Visible="@collection.GetVisibleByTabText("Weather")" Text="Weather">
18-
<Weather></Weather>
22+
<div class="tab-body">
23+
<Weather />
24+
</div>
1925
</DxTabPage>
20-
<DxTabPage CssClass="forms-tab" AllowClose="true" VisibleIndex="@collection.GetVisibleIndexByTabText("Forms")" Visible="@collection.GetVisibleByTabText("Forms")" Text="Forms">
21-
<Forms></Forms>
26+
<DxTabPage CssClass="form-tab" AllowClose="true" VisibleIndex="@collection.GetVisibleIndexByTabText("Form")" Visible="@collection.GetVisibleByTabText("Form")" Text="Form">
27+
<div class="tab-body">
28+
<Form />
29+
</div>
2230
</DxTabPage>
2331
</DxTabs>
2432
</div>

CS/DxBlazorApplication1/Components/Pages/Index.razor.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
::deep .welcome-gridlayout {
1+
.tab-body {
2+
padding: 20px 16px;
3+
}
4+
5+
::deep .welcome-gridlayout {
26
margin: auto;
37
width: auto;
48
height: auto;

CS/DxBlazorApplication1/Components/Pages/Weather.razor

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
@rendermode InteractiveServer
66
@inject WeatherForecastService ForecastService
77

8-
<PageTitle>Weather</PageTitle>
98
<h1>Weather</h1>
109

1110
@if (forecasts == null)
Lines changed: 3 additions & 0 deletions
Loading

README.md

Lines changed: 75 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,95 @@
11
<!-- default badges list -->
2-
![](https://img.shields.io/endpoint?url=https://codecentral.devexpress.com/api/v1/VersionRange/955986368/24.2.1%2B)
32
[![](https://img.shields.io/badge/Open_in_DevExpress_Support_Center-FF7200?style=flat-square&logo=DevExpress&logoColor=white)](https://supportcenter.devexpress.com/ticket/details/T1288385)
43
[![](https://img.shields.io/badge/📖_How_to_use_DevExpress_Examples-e9f6fc?style=flat-square)](https://docs.devexpress.com/GeneralInformation/403183)
54
[![](https://img.shields.io/badge/💬_Leave_Feedback-feecdd?style=flat-square)](#does-this-example-address-your-development-requirementsobjectives)
65
<!-- default badges end -->
7-
# Product/Platform - Task
6+
# Blazor Tabs - Create a Dynamic Tabbed Interface
87

9-
This is the repository template for creating new examples. Describe the solved task here.
8+
The example demonstrates how to create an interactive multi-tab web interface with DevExpress Blazor [Tabs](https://docs.devexpress.com/Blazor/405074/components/layout/tabs) and [Context Menu](https://docs.devexpress.com/Blazor/405060/components/navigation-controls/context-menu) components.
109

11-
Put a screenshot that illustrates the result here.
10+
![Multi-Tab UI](images/blazor-tabbed-ui.png)
1211

13-
Then, add implementation details (steps, code snippets, and other technical information in a free form), or add a link to an existing document with implementation details.
12+
It showcases core features that help end users build their personalized workspaces and multitask effectively.
13+
14+
### Organize Content Into Tabs
15+
16+
Place [DxTabs](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxTabs) container on the page (_Components/Pages/Index.razor_) and add a [DxTabPage](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxTabPage) for each tab.
17+
18+
Insert your custom Blazor components or content directly into each DxTabPage.
19+
20+
```razor
21+
<DxTabs @ref=tabs
22+
@bind-ActiveTabIndex=activeTabIndex
23+
AllowTabReorder="true"
24+
TabReordering="OnTabReordering"
25+
TabClosing="OnTabClosing"
26+
RenderMode="TabsRenderMode.AllTabs">
27+
<DxTabPage CssClass="counter-tab"
28+
AllowClose="true"
29+
VisibleIndex="@collection.GetVisibleIndexByTabText("Counter")"
30+
Visible="@collection.GetVisibleByTabText("Counter")"
31+
Text="Counter">
32+
<div class="tab-body">
33+
<Counter />
34+
</div>
35+
</DxTabPage>
36+
```
37+
38+
The CssClass property of a tab page serves as a unique identifier, allowing client-side scripts to interact with specific tabs.
39+
40+
### Persist Tab State
41+
42+
Implement a custom **MDITab** class to encapsulate specific properties of each individual tab. **MDITabCollection** will control visibility, display order, and titles of all tabs. The title links an underlying object to the visual tab representation in the UI.
43+
44+
Bind these properties to the visual tab elements in the UI. To ensure the MDITabCollection accurately reflects the live interface, implement event handlers for TabReorder and TabClosing. These handlers will listen for user actions and dynamically update the collection to match the current tab state.
45+
46+
To maintain the tab layout across sessions, serialize the collection to JSON and save it to the browser's local storage with **MDIStateHelper** class every time the UI layout changes. It maintains the tab visibility and order even after the user closes and reopens the browser. Tab state is restored in the OnAfterRenderAsync event handler.
47+
48+
### Add Context Menu to Tabs
49+
50+
Create a context menu that allows users to manage tabs:
51+
52+
- Close the current tab.
53+
- Close all tabs.
54+
- Close all tabs except for the current one.
55+
- Restore closed tabs.
56+
57+
Place [DxContextMenu](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxContextMenu) on the page (_Components/Pages/Index.razor_) and add a [DxContextMenuItem](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxContextMenuItem) for each menu action.
58+
59+
```razor
60+
<DxContextMenu @ref=menu>
61+
<Items>
62+
<DxContextMenuItem Click="CloseTab" Text="Close"></DxContextMenuItem>
63+
<DxContextMenuItem Click="CloseAllTabs" Text="Close All Tabs"></DxContextMenuItem>
64+
<DxContextMenuItem Click="CloseOtherTabs" Text="Close Other Tabs"></DxContextMenuItem>
65+
<DxContextMenuItem Click="RestoreAllTabs" Text="Restore Closed Tabs"></DxContextMenuItem>
66+
</Items>
67+
</DxContextMenu>
68+
```
69+
70+
Implement a client-side script (_wwwroot/js/mdi.js_) to handle right-clicks on specific tabs, identified by their CssClass property. This script should prevent the default browser context menu. Capture the mouse position, and invoke a .NET [JSInvokable] method.
1471

1572
## Files to Review
1673

17-
- link.cs (VB: link.vb)
18-
- link.js
19-
- ...
74+
- Index.razor
75+
- NavMenu.razor
76+
- MainLayout.razor
77+
- MDITab.cs
78+
- MDITabCollection.cs
79+
- MDIStateHelper.cs
80+
- mdi.js
2081

2182
## Documentation
2283

23-
- link
24-
- link
25-
- ...
84+
- [DxTabs Class](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxTabs)
85+
- [DxTabPage Class](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxTabPage)
86+
- [DxContextMenu Class](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxContextMenu)
87+
- [DxContextMenuItem Class](https://docs.devexpress.com/Blazor/DevExpress.Blazor.DxContextMenuItem)
2688

2789
## More Examples
2890

29-
- link
30-
- link
31-
- ...
91+
- [Form Layout for Blazor - Tabbed Wizard](https://github.com/DevExpress-Examples/Form-Layout-for-Blazor-Tabbed-Wizard)
92+
3293
<!-- feedback -->
3394
## Does this example address your development requirements/objectives?
3495

0 commit comments

Comments
 (0)