Bubbles
BubbleNotification is an extender that puts a small numeric badge, a bubble, next to any Wisej.NET control or ToolBarButton. Use it for unread counts, pending tasks, validation errors per field, or anything the user should notice at a glance. A bubble with value 0 is hidden, so a single call both shows and clears it. Clicking a bubble raises a server-side Click event.
Installation
Add the Wisej-4-Bubbles package to your Wisej.NET project:
dotnet add package Wisej-4-Bubbles
The package targets .NET Framework 4.8 and .NET 8 or later (including the -windows, Android, iOS and Mac Catalyst targets). After a rebuild, BubbleNotification shows up in the Visual Studio toolbox as a component.
Getting started
Drop a BubbleNotification on a page or form. Every control and toolbar button then gets two extender properties in the Properties window: BubbleValue on bubbleNotification1 and BubbleStyle on bubbleNotification1. In code, use SetBubbleValue and SetBubbleStyle:
- C#
- VB.NET
using Wisej.Web.Ext.Bubbles;
// Show 7 unread messages on the Inbox button.
this.bubbleNotification1.SetBubbleValue(this.buttonInbox, 7);
// Show it in the "warning" style instead of the default "alert".
this.bubbleNotification1.SetBubbleStyle(this.buttonInbox, BubbleStyle.Warning);
// Hide it again.
this.bubbleNotification1.SetBubbleValue(this.buttonInbox, 0);
Imports Wisej.Web.Ext.Bubbles
' Show 7 unread messages on the Inbox button.
Me.BubbleNotification1.SetBubbleValue(Me.ButtonInbox, 7)
' Show it in the "warning" style instead of the default "alert".
Me.BubbleNotification1.SetBubbleStyle(Me.ButtonInbox, BubbleStyle.Warning)
' Hide it again.
Me.BubbleNotification1.SetBubbleValue(Me.ButtonInbox, 0)
Properties and methods
| Member | Default | What it does |
|---|---|---|
SetBubbleValue(component, value) / GetBubbleValue | 0 | The number in the bubble. 0 hides it. |
SetBubbleStyle(component, style) / GetBubbleStyle | Alert | The bubble's style. |
Alignment | TopRight | Where the bubble sits on its control, as a ContentAlignment. |
Margin | 0 | Shifts the bubble away from the aligned position. |
Clear() | — | Removes every bubble this extender shows. |
Tag | null | Your own data. |
Alignment and Margin apply to every bubble of that extender. To position some bubbles differently, for example on the left of labels but on the right of buttons, use two BubbleNotification components.
this.bubbleNotification1.Alignment = ContentAlignment.MiddleRight;
this.bubbleNotification1.Margin = new Padding(0, 0, 4, 0);
Styles
BubbleStyle selects one of the states of the bubble appearance in the embedded BubbleNotifications.mixin.theme:
| Style | Theme state | Default colors |
|---|---|---|
Alert | default / alert | White on red (#C70039) |
Warning | warning | Black on amber (#FFC300) |
Critical | critical | White on purple (#9029AB) |
Custom | custom | Not defined by the mixin, so add it in your own. |
To change the colors, override bubble-alert-background, bubble-alert-text, bubble-warning-background, bubble-warning-text, bubble-critical-background and bubble-critical-text in your own mixin. For Custom, add a custom state to the bubble appearance:
{
"name": "MyApp.mixin",
"appearances": {
"bubble": {
"states": {
"custom": {
"styles": { "backgroundColor": "#0EA5E9", "color": "#0EA5E9" },
"properties": { "textColor": "white" }
}
}
}
}
}
See Theming.
Events
| Event | When |
|---|---|
Click | The user clicks a bubble. BubbleEventArgs gives you the Control and the Value it showed. |
private void bubbleNotification1_Click(object sender, BubbleEventArgs e)
{
if (e.Control == this.buttonInbox)
OpenInbox();
}
Clicking a bubble doesn't clear it. Reset the value yourself once the user has seen what it pointed to.
API reference
BubbleNotificationBubbleStyle,BubbleEventArgs- The whole
Wisej.Web.Ext.Bubblesnamespace