Gaps between RadDesktopAlerts

0 Answers 29 Views
DesktopAlert
David
Top achievements
Rank 1
David asked on 12 May 2022, 11:53 AM

Hi, 

I'm having a problem with RadDesktopAlertManager. I call multiple times high frequency to ShowAlert and CloseAlert, and sometimes a gaps between two consecutive alerts is created.

Martin Ivanov
Telerik team
commented on 16 May 2022, 10:52 AM

I've tested this, but couldn't reproduce any issues on my side. Can you check the attached project and tell me what I am missing? Also, can you send over a screenshot showing the issue?
David
Top achievements
Rank 1
commented on 17 May 2022, 11:44 AM

I'm attaching a screenshot
Martin Ivanov
Telerik team
commented on 17 May 2022, 12:06 PM

It looks like there is a custom style for the desktop alerts. Can you modify my project to show the customization and how exactly you position the alerts?
David
Top achievements
Rank 1
commented on 22 May 2022, 08:07 AM

I'm sorry, it's impossible for me to reproduce the issue because my application is very big and complex, and it doesn't happen in small project as the one you attached (I tried a lot).

I configured RadDesktopAlertManager to display alerts at AlertScreenPosition.BottomLeft, with some offset.

I'm using a custom style. Do you think that the style matters?

David
Top achievements
Rank 1
commented on 22 May 2022, 09:13 AM

I've tried now to remove my custom style, and the issue does reproduced in my application with default style.
David
Top achievements
Rank 1
commented on 23 May 2022, 07:35 AM

I've managed to reproduce it, please refer to the attached file (change its extension to xaml.cs - for some reason I wasn't able to attach cs file)

It happens when trying to add an alert as a result of other alert's Closed event.

Martin Ivanov
Telerik team
commented on 25 May 2022, 09:49 AM

Thank you for the file, David. This was very useful. Before that I was left with the impression that the issue was the margin between the alerts. However, now I see that you are talking about the space between the first alert and the bottom right part of the screen.

This happens because the alert manager is keeping an offset position so that it can stack alerts one over another. This offset is updated when the show/hide animation of the associated alert is executed. In your case, you are closing an alert, which fires its Closed event, but after this the close animation is still running, so the offset is not yet updated. To achieve your requirement, you will need to wait for the animation. One way to do so, is to use a dispatcher in order to delay the opening of the next alert. For example:

private void Alert_Closed(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
	var closedAlert = (RadDesktopAlert)sender;
	closedAlert.Closed -= Alert_Closed;
	m_alertsCollection.Remove(closedAlert);

	// Try add next alert
	var nextAlert = m_alertsCollection.FirstOrDefault();
	if (nextAlert != null)
	{
		Dispatcher.BeginInvoke(new Action(() =>
		{
			m_alertManager.ShowAlert(nextAlert);
		}), System.Windows.Threading.DispatcherPriority.ApplicationIdle);
	}
}

I hope that helps.

David
Top achievements
Rank 1
commented on 25 May 2022, 01:07 PM

Thank you for the answer, and I'm sorry about the misunderstanding (actually, in my real application there was also a margin between the alerts, but this is the same problem).

Your solution works indeed in our small application. But, my real application is very complex and consists of video and map components which do a lot of extended work in the UI thread, and I'm afraid that using ApplicationIdle priority will delay the alert appearance for unreasonable time. So I have a few questions/suggestions:

1) Is it safe enough to use ApplicationIdle in that scenario?

2) Is there any other event that notify when the animation running has ended?

3) Or, is there a constant value of milliseconds which I can wait (using a Timer or something like that) to ensure that animation running has ended, before calling ShowAlert?

Martin Ivanov
Telerik team
commented on 26 May 2022, 11:55 AM

(1) Using dispatcher doesn't guarantee that the code will execute at the expected time. However, from my experience I can say that it works pretty constant most of the time. If ApplicationIdle doesn't work for you, you can try different DispatcherPriority.

(2) There is no event for the animation end. You can disable the closing animation by calling the CloseAlert() method with its second parameter (useAnimation) set to False.

m_alertManager.CloseAlert(alert, false);
Or you can try the approach with the timer (I would recommend DispatcherTimer). The default duration of the fade animation that plays when the alert closes is 0.4 seconds.

David
Top achievements
Rank 1
commented on 31 May 2022, 11:48 AM

OK, I disable the animation as you suggested and it seems fine. Thanks!

No answers yet. Maybe you can help?

Tags
DesktopAlert
Asked by
David
Top achievements
Rank 1
Share this question
or