File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change
1
+ @using AstroPanda .Blazor .Toolkit .Services
2
+ <MudPaper >
3
+ <MudButton OnClick =" Close" >Close</MudButton >
4
+ </MudPaper >
5
+
6
+ @code {
7
+ [Inject ]
8
+ private IContextMenuService _contextService { get ; set ; }
9
+
10
+ [Inject ]
11
+ private ISnackbar _snackbar { get ; set ; }
12
+
13
+ private void Close ()
14
+ {
15
+ _snackbar .Add (" Close Pressed" );
16
+ _contextService .Close ();
17
+ }
18
+ }
Original file line number Diff line number Diff line change 1
1
@inherits LayoutComponentBase
2
2
@using AstroPanda .Blazor .Toolkit
3
+ @using AstroPanda .Blazor .Toolkit .Services
3
4
@using BlazorToolkit .Wasm .Components
5
+ @using AstroPanda .Blazor .Toolkit .Components
4
6
@using MudBlazor
5
7
6
8
<MyMudThemeProvider />
7
9
<MyMudProviders />
8
-
10
+ <ContextMenuProvider @ref =" cxt" />
11
+ <div class =" page" @onclick =" CloseContextMenus" >
9
12
<MudLayout >
10
13
<MudAppBar Elevation =" 0" >
11
14
<MudIconButton Icon =" @Icons.Material.Filled.Menu" Color =" Color.Inherit" Edge =" Edge.Start" OnClick =" @((e) => DrawerToggle())" />
24
27
</MudDrawerHeader >
25
28
<NavMenu />
26
29
</MudDrawer >
27
- <MudMainContent >
30
+ <MudMainContent >
31
+ <div @oncontextmenu =" OpenContextMenu" @oncontextmenu:preventDefault @oncontextmenu:stopPropagation >
28
32
<MudContainer MaxWidth =" MaxWidth.Large" Class =" my-16 pt-16" >
29
33
@Body
30
34
</MudContainer >
35
+ </div >
31
36
</MudMainContent >
32
37
</MudLayout >
38
+ </div >
33
39
34
40
@code {
41
+ [Inject ]
42
+ private IContextMenuService _contextService { get ; set ; }
43
+
35
44
bool _drawerOpen = true ;
45
+ private ContextMenuProvider cxt { get ; set ; }
36
46
37
47
void DrawerToggle ()
38
48
{
39
49
_drawerOpen = ! _drawerOpen ;
40
50
}
51
+
52
+ private void CloseContextMenus () => cxt .CloseAll ();
53
+
54
+ private void OpenContextMenu (MouseEventArgs e )
55
+ {
56
+ _contextService .Open <ExampleContextMenu >(e .ClientX , e .ClientY );
57
+ }
41
58
}
You can’t perform that action at this time.
0 commit comments