Skip to content

Commit 0cff3e6

Browse files
committed
Merge branch 'hotfix/hotfix-v31.2.2' of https://github.com/syncfusion-content/blazor-docs into 985195-UG
2 parents 504bf4d + 65c3dcc commit 0cff3e6

File tree

2 files changed

+35
-32
lines changed

2 files changed

+35
-32
lines changed
Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
layout: post
3-
title: Clear an Image with Blazor Image Editor Component | Syncfusion
4-
description: Learn here all about Clear an Image in Blazor Image Editor component in Blazor Server App and Blazor WebAssembly App.
3+
title: Render Image Editor in a Dialog Component | Syncfusion
4+
description: Render the Blazor Image Editor in a modal dialog for a focused, space-saving editing experience in Blazor Server and WebAssembly applications.
55
platform: Blazor
66
control: Image Editor
77
documentation: ug
88
---
99

1010
# Render Image Editor in Dialog Component
1111

12-
Rendering the Image Editor in a dialog involves displaying the image editor component within a modal dialog window, allowing users to edit images in a pop-up interface. This can be useful for maintaining a clean layout and providing a focused editing experience without navigating away from the current page.
12+
Rendering the Image Editor in a dialog displays the component within a modal window, enabling image editing in a pop-up interface. This approach helps maintain a clean layout and provides a focused editing experience without navigating away from the current page.
1313

1414
```cshtml
1515
@using Syncfusion.Blazor.ImageEditor
@@ -18,49 +18,52 @@ Rendering the Image Editor in a dialog involves displaying the image editor comp
1818
@using Syncfusion.Blazor.Inputs
1919
2020
<div style="padding-bottom: 15px">
21-
@if (this.ShowButton)
22-
{
23-
<SfButton OnClick="OpenDialogAsync">Open Image</SfButton>
24-
}
21+
<SfButton OnClick="OpenDialog">Edit Image</SfButton>
2522
</div>
26-
<SfDialog Height="75%" Width="435px" Target="#target" ShowCloseIcon="true" @bind-Visible="Visibility">
27-
<DialogTemplates>
28-
<Content>
29-
<div class="dialogContent">
30-
<SfImageEditor @ref="ImageEditor" Height="400px">
31-
</SfImageEditor>
32-
</div>
33-
</Content>
34-
</DialogTemplates>
35-
<DialogEvents OnOpen="@BeforeDialogOpen" Opened="OpenAsync" Closed="@DialogClosed"></DialogEvents>
3623
37-
</SfDialog>
24+
<div class="control-section" id="target" style="height: 500px">
25+
<SfDialog Width="600px" Height="500px" Target="#target" ShowCloseIcon="true" @bind-Visible="IsDialogVisible">
26+
<DialogEvents Opened="OnDialogOpened" Closed="OnDialogClosed"></DialogEvents>
27+
<DialogTemplates>
28+
<Content>
29+
<div class="dialog-content">
30+
@if (IsImageEditorOpened)
31+
{
32+
<SfImageEditor @ref="ImageEditor" Height="400px">
33+
<ImageEditorEvents Created="OnImageEditorCreated"></ImageEditorEvents>
34+
</SfImageEditor>
35+
}
36+
</div>
37+
</Content>
38+
</DialogTemplates>
39+
</SfDialog>
40+
</div>
3841
3942
@code {
40-
private bool Visibility { get; set; } = false;
41-
private bool ShowButton { get; set; } = true;
42-
SfImageEditor ImageEditor;
43+
private bool IsDialogVisible { get; set; } = false;
44+
private bool IsImageEditorOpened { get; set; } = false;
45+
private SfImageEditor ImageEditor;
4346
44-
private async void OpenDialogAsync()
45-
{
46-
this.Visibility = true;
47+
private void OpenDialog()
48+
{
49+
IsDialogVisible = true;
4750
}
4851
49-
private async void OpenAsync()
50-
{
51-
await ImageEditor.OpenAsync("https://ej2.syncfusion.com/react/demos/src/image-editor/images/bridge.png");
52+
private void OnDialogOpened()
53+
{
54+
IsImageEditorOpened = true;
5255
}
5356
54-
private void BeforeDialogOpen(BeforeOpenEventArgs args)
57+
private void OnDialogClosed()
5558
{
56-
this.ShowButton = false;
59+
IsImageEditorOpened = false;
5760
}
5861
59-
private void DialogClosed(CloseEventArgs args)
62+
private async void OnImageEditorCreated()
6063
{
61-
this.ShowButton = true;
64+
await ImageEditor.OpenAsync("https://ej2.syncfusion.com/react/demos/src/image-editor/images/bridge.png");
6265
}
6366
}
6467
```
6568

66-
![Blazor Image Editor with Resize the custom selection](../images/blazor-image-editor-dialog.jpg)
69+
![Blazor Image Editor rendered in a dialog](../images/blazor-image-editor-dialog.jpg)
-2.38 KB
Loading

0 commit comments

Comments
 (0)