Hi,
I've created a notification system for showing Toast Notifications to the user which other systems can publish notifications to. I want to update the content of Toast that has already been shown to the user, specifically to show the user a progress bar that shows the status of another system. I've tried two approaches to do this:
| <SfToast @ref="ToastObj" > <ToastTemplates> <Template> <div> @ToastContent </div> </Template> </ToastTemplates> </SfToast> <div class="col-lg-12 col-sm-12 col-md-12 center"> <div style="margin: auto; text-align: center"> <SfButton @onclick="@ShowToast"> Show Toast </SfButton> <SfButton @onclick="@Change"> Change content </SfButton> </div> </div> @code { SfToast ToastObj; public string ToastContent = "Initial content"; public void Change() { this.ToastContent = "Dynamic content"; } private async Task ShowToast() { await Task.Delay(100); this.ToastObj.ShowAsync(); } } |
The Toast template did work for setting dynamic content, thanks!
Is it possible to share position context like I mentioned in my second point?
| <SfToast @ref="ToastObj" > <ToastTemplates> <Template> <div> @ToastContent </div> </Template> </ToastTemplates> <ToastPosition X="@PositionX" Y="@PositionY"></ToastPosition> </SfToast> <div class="col-lg-12 col-sm-12 col-md-12 center"> <div style="margin: auto; text-align: center"> <SfButton @onclick="@ShowToast"> Show Toast </SfButton> <SfButton @onclick="@Change"> Change content </SfButton> </div> </div> @code { public bool flag = false; SfToast ToastObj; private string PositionX = "Center"; private string PositionY = "Bottom"; public string ToastContent = "Initial content"; public void Change() { this.ToastContent = "Dynamic content"; this.flag = true; } private async Task ShowToast() { await Task.Delay(100); this.ToastObj.ShowAsync(); } } |