File tree 7 files changed +69
-2
lines changed
BlazorSRRDemo/BlazorSRRDemo/Components/Pages
BlazorWebAssemblyDemo/Pages
7 files changed +69
-2
lines changed Original file line number Diff line number Diff line change
1
+ @page " /CustomButton"
2
+
3
+ <CustomClearButtonDemo @rendermode =" InteractiveServer" />
Original file line number Diff line number Diff line change
1
+ @page " /CustomButton"
2
+
3
+ <CustomClearButtonDemo />
Original file line number Diff line number Diff line change
1
+ @page " /CustomButton"
2
+
3
+ <CustomClearButtonDemo />
Original file line number Diff line number Diff line change 35
35
</NavLink >
36
36
</div >
37
37
38
+ <div class =" nav-item px-3" >
39
+ <NavLink class =" nav-link" href =" CustomButton" Match =" NavLinkMatch.All" >
40
+ <span class =" oi oi-home" aria-hidden =" true" ></span > Custom button
41
+ </NavLink >
42
+ </div >
43
+
38
44
<div class =" nav-item px-3" >
39
45
<NavLink class =" nav-link" href =" BGColorDemo" Match =" NavLinkMatch.All" >
40
46
<span class =" oi oi-home" aria-hidden =" true" ></span > BG Color
Original file line number Diff line number Diff line change
1
+ @inject NavigationManager navigationManager
2
+ @inject SignatureInMemoryService memoryService
3
+
4
+ <h1 >SignaturePad Custom Clear Button Demo</h1 >
5
+ <SignaturePad @bind-Value =" Input.Signature" style =" width : 100% ;" >
6
+ <ClearButtonTemplate Context =" pad" >
7
+ <button type =" button" class =" btn btn-danger" @onclick =" pad.Clear" >Clear</button >
8
+ </ClearButtonTemplate >
9
+ </SignaturePad >
10
+
11
+
12
+ @if (Input .Signature .Any ())
13
+ {
14
+ <h2 >Signature </h2 >
15
+ <img src =" @Input.SignatureAsBase64" />
16
+ <button type =" button" class =" btn btn-primary" @onclick =" SaveSignature" >Save signature </button >
17
+ <button type =" button" class =" btn btn-primary" @onclick =" OpenSignature" >Open signature </button >
18
+ }
19
+
20
+ @if (memoryService .Signature .Any ())
21
+ {
22
+ <button type =" button" class =" btn btn-primary ms-1" @onclick =" ReadSignature" >Read signature </button >
23
+ }
24
+
25
+ @code {
26
+ public MyInput Input { get ; set ; } = new ();
27
+ private SignaturePad signaturePad = default ! ;
28
+
29
+ private void SaveSignature ()
30
+ {
31
+ memoryService .Signature = Input .Signature ;
32
+ }
33
+
34
+ private void OpenSignature ()
35
+ {
36
+ navigationManager .NavigateTo (Input .SignatureAsBase64 );
37
+ }
38
+
39
+ private void ReadSignature ()
40
+ {
41
+ Input .Signature = memoryService .Signature ;
42
+ StateHasChanged ();
43
+ }
44
+ }
Original file line number Diff line number Diff line change 7
7
8
8
@if (ShowClearButton && ! Disabled )
9
9
{
10
- <button type =" button" class =" @ClearButtonClass" @onclick =" Clear" >@ClearButtonText </button >
10
+ if (ClearButtonTemplate is not null )
11
+ {
12
+ @ClearButtonTemplate (this );
13
+ }
14
+ else
15
+ {
16
+ <button type =" button" class =" @ClearButtonClass" @onclick =" Clear" >@ClearButtonText </button >
17
+ }
11
18
}
12
19
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ public partial class SignaturePad
27
27
public string ClearButtonText { get ; set ; } = "Clear Signature" ;
28
28
[ Parameter ]
29
29
public bool Disabled { get ; set ; }
30
-
30
+ [ Parameter ]
31
+ public RenderFragment < SignaturePad > ? ClearButtonTemplate { get ; set ; }
31
32
32
33
33
34
/// <summary>
You can’t perform that action at this time.
0 commit comments