New to Telerik UI for WPF? Download free 30-day trial

DesktopAlertManager

Using RadDesktopAlertManager you could easily visualize and position RadDesktopAlert on the screen. Thanks to RadDesktopAlertManager, you could also display multiple alerts on the screen - it will calculate the location of all alerts so they could not overlap. When an alert gets closed, all other alerts that are currently visualized on the screen get relocated.

You can initialize RadDesktopAlertManager using one of the following constructors:

Initializing of RadDesktopAlertManager

var manager = new RadDesktopAlertManager(); 
manager = new RadDesktopAlertManager(AlertScreenPosition.BottomCenter); 
manager = new RadDesktopAlertManager(AlertScreenPosition.TopCenter, 5); 
manager = new RadDesktopAlertManager(AlertScreenPosition.TopRight, new Point(0, 0)); 
manager = new RadDesktopAlertManager(AlertScreenPosition.BottomCenter, new Point(0, 0), 10); 
Dim manager = New RadDesktopAlertManager() 
manager = New RadDesktopAlertManager(AlertScreenPosition.BottomCenter) 
manager = New RadDesktopAlertManager(AlertScreenPosition.TopCenter, 5) 
manager = New RadDesktopAlertManager(AlertScreenPosition.TopRight, New Point(0, 0)) 
manager = New RadDesktopAlertManager(AlertScreenPosition.BottomCenter, New Point(0, 0), 10) 

This article will provide some detailed information about the following properties of RadDesktopAlertManager:

And the following methods of RadDesktopAlertManager:

ShowAlert()

In order for RadDesktopAlert to be visualized you need to pass it as a parameter to the ShowAlert method of RadDesktopAlertManager.

Example 1 demonstrates how to visualize RadDesktopAlert.

Example 1: Showing RadDesktopAlert

var alert = new RadDesktopAlert 
{ 
    Header = "MAIL NOTIFICATION", 
    Content = "Hello, Here are two things that we noticed today on our daily meeting.", 
    Command = new DelegateCommand(this.OnCommandExecuted), 
    ShowDuration = 5000, 
}; 
manager.ShowAlert(alert); 
Dim alert = New RadDesktopAlert() With { 
     .Header = "MAIL NOTIFICATION", 
     .Content = "Hello, Here are two things that we noticed today on our daily meeting.", 
     .Command = New DelegateCommand(OnCommandExecuted), 
     .ShowDuration = 5000 
} 
manager.ShowAlert(alert) 

By default, RadDesktopAlert is shown and closed with an animation. However, there are some cases when you might need to disable these animations. You could easily disable the ShowAnimation by setting the second parameter of the ShowAlert method to false. Telerik introduced this feature with the Q3 2015 version release of UI for WPF:

Example 2: Show RadDesktopAlert without animation

manager.ShowAlert(new DesktopAlertParameters 
{ 
    Header = "New mail", 
    Content = "Hello, Here are two things that we noticed today on our front-end meeting", 
    Icon = new Image { Source = Application.Current.FindResource("DesktopAlertIcon") as ImageSource, Width = 48, Height = 48 }, 
    IconColumnWidth = 48, 
    IconMargin = new Thickness(10, 0, 20, 0) 
}, false); 
manager.ShowAlert(New DesktopAlertParameters() With { 
     .Header = "New mail", 
     .Content = "Hello, Here are two things that we noticed today on our meeting", 
     .Icon = New Image() With { 
         .Source = TryCast(Application.Current.FindResource("DesktopAlertIcon"), ImageSource), 
         .Width = 48, 
         .Height = 48 
    }, 
     .IconColumnWidth = 48, 
     .IconMargin = New Thickness(10, 0, 20, 0) 
}, False) 

ShowAlert() MVVM

RadDesktopAlert could also be visualized by passing an object of type DesktopAlertParameters to the ShowAlert method. This class that holds all parameters that you need to customize RadDesktopAlert and it is MVVM friendly. It was created to visualize and customize RadDesktopAlert within MVVM scenarios.

Example 3 demonstrates how to display an alert in a MVVM scenario:

Example 3: Creating RadDesktopAlert in MVVM

manager.ShowAlert(new DesktopAlertParameters 
{ 
    Header = "New mail", 
    Content = "Hello, Here are two things that we noticed today on our front-end meeting", 
    Icon = new Image { Source = Application.Current.FindResource("DesktopAlertIcon") as ImageSource, Width = 48, Height = 48 }, 
    IconColumnWidth = 48, 
    IconMargin = new Thickness(10, 0, 20, 0), 
    Sound = System.Media.SystemSounds.Beep 
}); 
manager.ShowAlert(New DesktopAlertParameters() With { 
     .Header = "New mail", 
     .Content = "Hello, Here are two things that we noticed today on our meeting", 
     .Icon = New Image() With { 
         .Source = TryCast(Application.Current.FindResource("DesktopAlertIcon"), ImageSource), 
         .Width = 48, 
         .Height = 48 
    }, 
     .IconColumnWidth = 48, 
     .IconMargin = New Thickness(10, 0, 20, 0) 
}) 

CloseAlert() and CloseAllAlerts()

You could close RadDesktopAlert in code behind before its duration has expired using the CloseAlert method of RadDesktopAlertManager. The DesktopAlert control you want to close should be passed as a parameter to this method.

Example 4 shows how to close RadDesktopAlert:

Example 4: Closing single RadDesktopAlert

manager.CloseAlert(alert); 
manager.CloseAlert(alert) 

Using the CloseAllAlerts method of RadDesktopAlertManager, all currently opened RadDesktopAlerts could be closed.

Example 5 demonstrates how to close all opened RadDesktopAlerts:

Example 5: Closing all RadDesktopAlerts

manager.CloseAllAlerts(); 
manager.CloseAllAlerts() 

If you want to close RadDesktopAlert without using an animation you need to pass false as a second parameter for the CloseAlert method and as a first parameter for the CloseAllAlerts method. Telerik introduced this feature with the Q3 2015 release of UI for WPF:

Example 6 demonstrates how to close RadDesktopAlert without using an animation:

Example 6: Closing RadDesktopAlert without an animation

manager.CloseAlert(alert, false); 
manager.CloseAllAlerts(false); 
manager.CloseAlert(alert, False) 
manager.CloseAllAlerts(False) 

GetAllAlerts()

You could easily get a collection of all currently opened RadDesktopAlerts using the GetAllAlerts method introduced with Q3 2015 release version of UI for WPF. By calling it an IEnumerable collection with RadDesktopAlerts will be returned.

Example 7 shows how to get all RadDesktopAlert:

Example 7: Getting all opened RadDesktopAlerts

IEnumerable alerts = manager.GetAllAlerts(); 
Dim alerts As IEnumerable = manager.GetAllAlerts() 

Show/Hide Animation

Using the ShowAnimation and HideAnimation properties of RadDesktopAlertManager you could easily apply a custom Animation or group animations. That animation will start when you show or hide a RadDesktopAlert on the screen.

Example 8: Applying ShowAnimation - FadeAnimation

manager.ShowAnimation = new FadeAnimation 
{ 
    Direction = AnimationDirection.Out, 
    MinOpacity = 0.5d, 
    MaxOpacity = 0.9d, 
    SpeedRatio = 0.5d 
}; 
manager.ShowAnimation = New FadeAnimation() With 
{ 
     .Direction = AnimationDirection.Out, 
     .MinOpacity = 0.5, 
     .MaxOpacity = 0.9, 
     .SpeedRatio = 0.5 
} 

Example 9: Applying ShowAnimation - RevealAnimation

manager.ShowAnimation = new RevealAnimation() 
{ 
    Duration = TimeSpan.FromMilliseconds(1000), 
    Orientation = Orientation.Horizontal, 
    AnimationDirection = AnimationDirection.In, 
}; 
manager.ShowAnimation = new RevealAnimation() With 
{ 
    .Duration = TimeSpan.FromMilliseconds(1000), 
    .Orientation = Orientation.Horizontal, 
    .AnimationDirection = AnimationDirection.In, 
} 

If you set a Show/HideAnimation to null in order to disable it during runtime it will affect the next RadDesktopAlert that will be shown or hidden.

ScreenPosition

Using the ScreenPosition property you could easily define the position of where you want RadDesktopAlert to be visualized. It accepts a value of type AlertScreenPosition. The screen positions you can set are as follows:

  • TopLeft

  • TopCenter

  • TopRight

  • BottomLeft

  • BottomCenter

  • BottomRight

The ScreenPosition property is initialized and set only through RadDesktopAlertManager's constructor.

AlertsDistance

You could easily set the distance between the currently open RadDesktopAlerts using the AlertsDistance property of the RadDesktopAlertManager. If the property is changed during runtime, it will immediately number the open RadDesktopAlerts and the distance between them will be changed according to the newly applied value.

AlertsReorderAnimationDuration

With Q3 2015 released version of WPF a brand new property AlertsReorderAnimationDuration was introduce. It is of type integer and represents the number of milliseconds the animation used for updating the order of all instances of RadDesktopAlert.

Example 10: Setting AlertsReorderAnimationDuration

manager.AlertsReorderAnimationDuration = 1000; 
manager.AlertsReorderAnimationDuration = 1000 

See Also

In this article