wpf desktop alert

1 Answer 44 Views
DesktopAlert
Sarah
Top achievements
Rank 1
Iron
Sarah asked on 01 Oct 2024, 07:17 AM
hello
I used desktop alert. The height of my desktop alerts is different, and the sum of their height is sometimes higher than the height of the monitor. User closes Desktop Alert 
 And then it scrolls automatically and the rest is displayed. 
1. How can I find out which Desktop Alert is being viewed by the user on the monitor and which Desktop Alert is not visible due to the large number of Desktop Alerts? Sometimes I want to close all the desktop alerts that the user sees on the monitor so that the rest is displayed, and so on.
2. If the number of desktop alerts is large and their total height is greater than the height of the monitor, is it possible to display the scroll so that the user can see the entire desktop alert by scrolling?

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 03 Oct 2024, 01:22 PM

Hello Sarah,

(1) All desktop alerts are within the screen bounds. When you reach the screen bounds, the alerts will start to stack up aligned with the top of the screen. If you want to remove some alerts before they auto-close, you can close them based on their order of appearance.

An idea that you can explore would be, to check if the summary of all alert heights is bigger than the screen height, and if so, remove the older alerts. For example:

private void ShowAlert(object header, object content, double height)
 {
     alertsManager.ShowAlert(new RadDesktopAlert()
     {
         CanAutoClose = false,
Height = height, Header = header, Content = content
}); var alerts = alertsManager.GetAllAlerts().ToList(); var sumHeight = alerts.Sum(s => s.Height); var heightDelta = SystemParameters.FullPrimaryScreenHeight - sumHeight; if (heightDelta < 0) // the sumHeight exceeds the screen height { while (heightDelta < 0) { var firstAlert = alerts.First(); heightDelta += firstAlert.Height; alertsManager.CloseAlert(firstAlert); } } }

(2) The desktop alert component doesn't have a scrolling functionality for the stack of alerts. Basically, each alert is opened in a new Window which is positioned above the previously opened Window (alert). However, you can achieve your requirement with some custom code. Basically, instead of using the RadDesktopAlertManager class to show the alerts, you can open your customized Window that is positioned on the right side of the screen and manually add the RadDesktopAlert instances in it. In the Window you can have a ScrollViewer with an ItemsControl that hosts the alerts. I have attached a small sample showing this idea. Note that the project merely illustrates the suggestion and it may need few extra adjustments to work as expected.

I hope these ideas help.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
DesktopAlert
Asked by
Sarah
Top achievements
Rank 1
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or