Popup
The RadNotifyIcon allows for displaying a popup upon interacting with the icon or by manually calling the exposed methods.
PopupContent and PopupContentTemplate
The PopupContent and PopupContentTemplate properties allow for setting the popup's content and changing its default look. Whatever is set to the PopupContent will be the DataContext inside the PopupContentTemplate. Example 1 demonstrates how you can setup those properties.
Example 1: Setting PopupContent and PopupContentTemplate
<telerik:RadNotifyIcon
x:Name="icon"
PopupContent="Hello, world!"
PopupActivationMouseEvent = "LeftClick">
<telerik:RadNotifyIcon.PopupContentTemplate>
<DataTemplate>
<Border Background="Bisque">
<TextBlock Text="{Binding}" Padding="10"/>
</Border>
</DataTemplate>
</telerik:RadNotifyIcon.PopupContentTemplate>
</telerik:RadNotifyIcon>
Figure 1: RadNotifyIcon with activated popup
PopupActivationMouseEvent
The PopupActivationMouseEvent property determines when the popup will be shown. The default value is LeftClick.
Example 2: Setting PopupActivationMouseEvent
<telerik:RadNotifyIcon PopupActivationMouseEvent="LeftDoubleClick" />
PopupShowDuration
The PopupShowDuration specifies the amount of time in milliseconds after which the popup will begin to close automatically. The default value is 5000 milliseconds (5s).
Example 3: Setting PopupShowDuration
<telerik:RadNotifyIcon PopupShowDuration="10000" />
PopupCloseMode
The PopupCloseMode is a bitwise enumeration, which controls the actions that will close the popup. The possible values are:
- None: The popup can only be closed in code (with the HidePopup method) or by clicking on the notify icon.
- Deactivate: The popup can be closed by clicking outside of it or by deactivating it with a windows keyboard shortcut.
- Timeout: The popup will be closed after the time specified by the PopupShowDuration runs out. This is the default value.
Example 4: Closing the popup on deactivation or timeout
<telerik:RadNotifyIcon PopupCloseMode="Deactivate, TimeOut" />
Programmatically Showing the Popup
The RadNotifyIcon allows for programmatically showing a popup through the ShowPopup method. It exposes one overload, which provides the option of specifying a screen location.
- void ShowPopup(): Shows the popup on top of the notify icon.
-
void ShowPopup(Point location): Shows the popup at the provided location.
Example 5: Using the ShowPopup method
this.icon.ShowPopup();
Me.icon.ShowPopup()
Programmatically Hiding the Popup
You can manually hide the popup with the HidePopup method as shown in Example 6.
Example 6: Using the HidePopup method
this.icon.HidePopup();
Me.icon.HidePopup()
Popup animations
You can control the opening and closing animation with the PopupShowAnimation and PopupHideAnimation properties respectively. They expect an animation of type RadAnimation and by default FadeAnimations are used.
Example 7: Setting PopupShowAnimation and PopupHideAnimation
<Grid>
<Grid.Resources>
<telerik:ScaleAnimation x:Key="showAnimation" MinScale="0.1" MaxScale="0.9" Duration="00:00:02" />
<telerik:ScaleAnimation x:Key="hideAnimation" MinScale="0.9" MaxScale="0.1" Duration="00:00:02" />
</Grid.Resources>
<telerik:RadNotifyIcon
x:Name="icon"
PopupContent="Hello, world!"
PopupActivationMouseEvent = "LeftDoubleClick"
PopupShowAnimation="{StaticResource showAnimation}"
PopupHideAnimation="{StaticResource hideAnimation}">
<telerik:RadNotifyIcon.PopupContentTemplate>
<DataTemplate>
<Border Background="Bisque">
<TextBlock Text="{Binding}" Padding="10"/>
</Border>
</DataTemplate>
</telerik:RadNotifyIcon.PopupContentTemplate>
</telerik:RadNotifyIcon>
</Grid>
IsPopupOpen
The IsPopupOpen property allows you to check whether a popup is currently open.
Example 8: Using IsPopupOpen
var isOpen = this.icon.IsPopupOpen;
Dim isOpen = Me.icon.IsPopupOpen