Version

WinTree Using the Notification Badge

This topic demonstrates the usage of the NotificationBadge properties of the UltraTree.

Overview

The Notification Badges allow you to notify your users about every important event that requires their attention. Almost all of the settings related to notification badges are exposed in the NotificationBadgeSettings property, which can be found on various levels throughout the UltraTree – you can find them on the Override property contained by the Tree and by each Node. The settings are resolved by using first the more specific instance and then the more general ones. For example, if we show a notification badge on a node on the tree, the notification settings on the node will take precedence over the notification settings on the tree. The only property related to the NotificationBadges that isn’t part of the NotificationBadgeSettings class is the NotificationBadgeText, which can be found directly on each node.

The size of the NotificationBadges is determined by the size of its contents and it is limited by the size of the DisplayArea. If you have a badge with text, the size of the notification will be the size needed to display the text with the specified font, as long as this size isn’t bigger than its display area. If you show an image, the NotificationBadge will use the image size (again if it isn’t bigger than its display area).

Appearance Properties

The NotificationBadgeSettings property exposes an Appearance property. The NotificationBadgeSettings property is exposed on the Override, which is exposed on the tree, each node, and each Nodes collection. By default the notification badges will use a red background, red borders and a white foreground with a bold font.

In C#:

// Make the font size of the Notifications 8pt
this.ultraTree1.Override.NotificationBadgeSettings.Appearance.FontData.SizeInPoints = 8;
// Use smaller size for the Notifications
this.ultraTree1.Override.NotificationBadgeSettings.Appearance.FontData.SizeInPoints = 5.5f;
// Use Calibri font for all nodes
this.ultraTree1.Override.NotificationBadgeSettings.Appearance.FontData.Name = "Calibri";

In Visual Basic:

' Make the font size of the Notifications 8pt
Me.UltraTree1.Override.NotificationBadgeSettings.Appearance.FontData.SizeInPoints = 8
' Use smaller size for the Notifications
Me.UltraTree1.Override.NotificationBadgeSettings.Appearance.FontData.SizeInPoints = 5.5F
' Use Calibri font for all nodes
Me.UltraTree1.Override.NotificationBadgeSettings.Appearance.FontData.Name = "Calibri"

Style Property

The style properties for the NotificationBadgeSettings are the BorderStyle and DisplayShadow. BorderStyle determines the border style used by the notification, while DisplayShadow determines whether the notification will have a shadow.

The default border style is Rounded3 and the Notifications won’t show shadows by default. The shadow color is Gray by default and can be controlled by the BorderColor3DBase property of the notification appearances.

In C#:

// Display shadows around the NotificationBadges
this.ultraTree1.Override.NotificationBadgeSettings.DisplayShadow = DefaultableBoolean.True;
// Set the NotificationBadges BorderStyle to Rounded1
this.ultraTree1.Override.NotificationBadgeSettings.BorderStyle = UIElementBorderStyle.Rounded1;

In Visual Basic:

' Display shadows around the NotificationBadges
Me.UltraTree1.Override.NotificationBadgeSettings.DisplayShadow = DefaultableBoolean.[True]
'Set the NotificationBadges BorderStyle to Rounded1
Me.UltraTree1.Override.NotificationBadgeSettings.BorderStyle = UIElementBorderStyle.Rounded1

Visibility Property

The Visibility property determines under which circumstances the Tree will show the NotificationBadges. By default it is set to NonNullOrEmpty which means that the NotificationBadge will show only if there is content for it – if there is text or an image assigned to the NotificationBadge. You can make the NotificationBadges always appear, even if they have no content, by setting Visibility to Always or hide them by setting it to Never. Setting Visibility to never can be useful to prevent the NotificationBadges from appearing in places where you don’t want them.

In C#:

// Prevent the NotificationBadges from appearing
this.ultraTree1.Override.NotificationBadgeSettings.Visibility = NotificationBadgeVisibility.Never;

In Visual Basic:

' Prevent the NotificationBadges from appearing
Me.UltraTree1.Override.NotificationBadgeSettings.Visibility = NotificationBadgeVisibility.Never

NotificationBadgeText property

This property is not part of the NotificationBadgeSettings class, but a separate one, which is directly on the node. It determines the text that is displayed by the NotificationBadge.

In C#:

// Set the notification text displayed by the nodes
node1.NotificationBadgeText = "7";
node2.NotificationBadgeText = "New!";

In Visual Basic:

' Set the notification text displayed by the nodes
Node1.NotificationBadgeText = "7"
Node2.NotificationBadgeText = "New!"