微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Blazor已同步确认同步融合

如何解决Blazor已同步确认同步融合

是否可以有Blazor Syncfusion确认和提示对话框的同步版本?

是从方法显示模式对话框,等待是/否确认,返回用户输入并继续最初显示对话框的方法吗?

解决方法

我们已经验证了所报告的查询。是的,您可以使用lambda表达式基于单击的SfDialog按钮执行操作。检查下面的代码块以供参考。

@using Syncfusion.Blazor.Popups 
@using Syncfusion.Blazor.Buttons 
 
<SfButton @onclick="@OpenDialog">Open Dialog</SfButton> 
 
<SfDialog Width="250px" ShowCloseIcon="true" IsModal="true" @bind-Visible="@IsVisible"> 
    <DialogTemplates> 
        <Header> Dialog </Header> 
        <Content> This is a Dialog with button and primary button </Content> 
    </DialogTemplates> 
    <DialogButtons> 
        <DialogButton Content="Confirm" IsPrimary="true" OnClick='(e => CloseDialog("Yes"))' /> 
        <DialogButton Content="Cancel" OnClick='(e => CloseDialog("No"))' /> 
    </DialogButtons> 
</SfDialog>
 
@code { 
    private bool IsVisible { get; set; } = true; 
 
    private void OpenDialog() 
    { 
        this.IsVisible = true; 
    } 
 
    private void CloseDialog(string userResponse) 
    { 
        if (userResponse == "Yes") 
        { 
            // Perform your action 
            this.IsVisible = false; 
        } else 
        { 
            this.IsVisible = true; 
        } 
    } 
} 

如果解决方案有帮助,请告诉我们

,

感谢NDRA JITH,

您的建议包含两种方法,如果可以使用一种方法,那将是很好的选择,就像JavaScript中的Confirm方法一样。因此,请打开“确认”对话框,等待用户回答,并根据回答以相同的方法继续进行。

在Blazored中可以(但我想在Syncfusion中使用)以下代码:

父屏幕:

@inject IModalService Modal

<BlazoredModal />

@code {
  var modalImport = Modal.Show<ModalImport>("Title comes here");
  var result = await modalImport.Result;
  if (!result.Cancelled)
  {
    var doSomethingWithThisResult = result.Data;
  }
}

模式屏幕:

@inject IModalService ModalService;
<button  @onclick="HandleStartImport" class="btn btn-secondary">Start</button>
<button @onclick="No" class="btn btn-secondary">Cancel</button>

@code {
  [CascadingParameter] BlazoredModalInstance BlazoredModal { get; set; }
  
  async Task HandleStartImport()
  {
    BlazoredModal.Close(ModalResult.Ok("I clicked OK!"));
  }
  void No() => BlazoredModal.Cancel();
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。