Hello,
I'm having a
problem with RadDesktopAlertManager.
Since its
position can't be changed after initialization, I have to re-assign it in order
to change the position. But after doing that, adding of a new RadDesktopAlert
item to the manager causes a "Closed" event to be raised for the alert immediately after that (I can see in the Call Stack that the item's adding
caused the event raising). Actually the item is not being closed (which is
good), but the unnecessary event effects my business logic.
12 Answers, 1 is accepted
Thank you for the description.
Attached I'm sending you the sample project. Please, review it and if necessary update it with your logic and send it back to me so that I can further assist you.
Regards,
Dimitar Dinev
Progress Telerik
Hi Dimitar,
Thanks for the answer.
I see what happens. In my code, before re-instantiating the manager, I'm closing all the displaying alerts. The Closed event refers to those alerts, probably. The confusing thing is that it is being raised only after calling ShowAlert (after the re-instantiation), and not immediately after the call to CloseAllAlerts (as one would except).
Thank you for the feedback.
As you described, I used the CloseAllAlerts method but the Closed event is raised as soon as the fading animation completes at my end and not after the ShowAlert method is invoked.
I've made a small update in the attached sample project to demonstrate my approach. Please, review it and if I'm missing something of importance, update it with your logic and send it back to me. I will be awaiting your reply.
Regards,
Dimitar Dinev
Progress Telerik
Hi Dimitar,
Thanks for the answer.
I ran the sample you attached, and placed two breakpoints:
1 - In the line "manager.ShowAlert(alert);"
2 - In the begging of the method "Alert_Closed"
The debugger first stopped in the 1st breakpoint, then it stopped in the 2nd one.
When I click Button_Click_1 the ShowAlert() method is called first at my end as you've described. The Alert_Closed method, however, is only called when the second button is clicked and the CloseAllAlerts() method is executed, which is expected.
Could you please confirm that these are the same action steps you're taking at your end?
If you're aiming for something different, please provide more details on your exact requirement so that I can further assist you. I will be awaiting your reply.
Regards,
Dimitar Dinev
Progress Telerik
Hi Dimitar,
I'm sorry for the misunderstood. I repeat the steps you write and got the same result. But, this is not the problem. In my previous post I mentioned that I placed two breakpoints, and the first one is in the line "manager.ShowAlert(alert);". I mean to the line that is in the method Button_Click_2. The Alert_Closed method is only called after that line (meaning, after ending the execution of Button_Click_2).
Thank you for the clarification.
The reason why the breakpoint on manager.ShowAlert(alert) in Button_Click_2 is triggered first is because the CloseAllAlerts() method has a default fading animation which causes a delay in the alert's closing. Here is the method definition:
public
void
CloseAllAlerts(
bool
useAnimations =
true
)
{
var alerts =
new
List<RadDesktopAlert>(
this
.openedAlerts);
alerts.ForEach(alert =>
this
.CloseAlert(alert, useAnimations));
this
.openedAlertsTotalHeight = 0;
}
You can ensure that the Closed event handler is called before the ShowAlert method by setting the bool value in ​Button_Click_2 to false ​like this:
private
void
Button_Click_2(
object
sender, RoutedEventArgs e)
{
var alert = manager.GetAllAlerts().FirstOrDefault();
manager.CloseAllAlerts(
false
);
manager =
new
RadDesktopAlertManager(AlertScreenPosition.TopRight);
manager.ShowAlert(alert);
}
Please let me know if this approach works for you.
Regards,
Dimitar Dinev
Progress Telerik
No, it didn't help...
I changed the argument value to false but the Alert_Closed method is still being called after the call to manager.ShowAlert(alert).
Attached I'm sending you a short video capture from my screen showcasing the code and behavior at my end. You can observe that the Closed event handler is called before the ShowAlert method on my machine.
Could you please review it and give me feedback on whether your behavior differentiates from this one?
Regards,
Dimitar Dinev
Progress Telerik
Hi Dimitar,
That's very strange! When running the same code in my machine, the behavior is different. Maybe it's a bug that was solved in a newer version? I'm having an old version of Telerik installed (from 2016)
I tested it with the 2016 R1 version and indeed the breakpoint on ShowAlert is hit first. This issue has been fixed in newer versions, so I would advise you to upgrade.
You can learn more on how to Donwload New Versions and how to Upgrade the Wizard on the links provided.
Regards,
Dimitar Dinev
Progress Telerik