InfoBadge
- Assembly:
Fluence.Wpf - Namespace:
Fluence.Wpf.Controls
public class InfoBadge : ContentControl
A small badge overlay that displays a numeric value, icon, or dot indicator. Typically attached to a NavigationViewItem or other control.
Remarks: Content is driven by the badge itself: it carries the value's text, the icon element, or nothing at all, depending on which display kind Value and IconSource resolve to. WinUI's InfoBadge has no content surface at all (InfoBadge.idl declares only Value, IconSource and TemplateSettings); here it is an artifact of the WPF base class, so a value assigned to it directly is overwritten the next time either property changes. Set Value or IconSource instead.
Base type: ContentControl (including inherited WPF and .NET members)
Constructors
InfoBadge
public InfoBadge()
Creates a new InfoBadge instance.
Properties
BadgeStyle
public InfoBadgeStyle BadgeStyle { get; set; }
Gets or sets the severity style of the badge.
CornerRadius
public CornerRadius CornerRadius { get; set; }
Gets or sets the corner radius of the badge. Left alone it follows the badge's own height, staying a capsule at any size; set locally it is honoured as given, which is what WinUI's own InfoBadge.cpp does with a local value.
Remarks: This preserves parity rather than adding to it. WinUI's InfoBadge inherits CornerRadius from its own Control base and reads it to honour a local value; WPF's Control has no such property, so the badge declares it.
IconSource
public object IconSource { get; set; }
Gets or sets an icon element to display inside the badge (overrides Value text).
Value
public int Value { get; set; }
Gets or sets the numeric value displayed. Set to -1, the default, to show a dot instead. Anything below -1 is rejected: WinUI throws for it (InfoBadge.cpp), because a negative count has no badge to render and folding it into the dot would hide the bug instead of reporting it.
Methods
GetStyleGlyph
public static string GetStyleGlyph(InfoBadgeStyle badgeStyle)
Returns the canonical Segoe Fluent glyph for a badge severity, so a consumer can build the icon form of a badge without hardcoding codepoints, in the same shape as GetSeverityGlyph.
Remarks: WinUI ships a dot, a value and an icon style per severity, and only the icon styles carry a glyph (InfoBadge_themeresources.xaml). Fluence expresses severity as one BadgeStyle property, so the badge cannot pick the icon form for you without taking the dot form away: assign the glyph to IconSource when you want it. The values are WinUI's own, and the icon styles for Attention and Informational also inset the glyph by 0,4,0,2.
Parameter badgeStyle: The severity to return the glyph for.
Returns: The glyph character for badgeStyle.
Exception System.ArgumentOutOfRangeException: badgeStyle is not a defined InfoBadgeStyle value.
MeasureOverride
protected override Size MeasureOverride(Size constraint)
Documentation inherited from the ContentControl API.
Remarks: A badge is never narrower than it is tall: WinUI squares it up when the natural width comes out under the height (InfoBadge.cpp``MeasureOverride), which is what turns a single digit value into a circle rather than a squashed oval. With the 4 dip minimum width WinUI's own metrics carry, nothing else would hold that shape.
OnApplyTemplate
public override void OnApplyTemplate()
Documentation inherited from the ContentControl API.
OnCreateAutomationPeer
protected override AutomationPeer OnCreateAutomationPeer()
Documentation inherited from the ContentControl API.
OnRenderSizeChanged
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
Documentation inherited from the ContentControl API.
Dependency property identifiers
Use these identifiers with WPF property APIs. The matching CLR properties appear above when the control exposes them.
BadgeStyleProperty
public static readonly DependencyProperty BadgeStyleProperty
Identifies the BadgeStyle dependency property.
CornerRadiusProperty
public static readonly DependencyProperty CornerRadiusProperty
Identifies the CornerRadius dependency property.
IconSourceProperty
public static readonly DependencyProperty IconSourceProperty
Identifies the IconSource dependency property.
ValueProperty
public static readonly DependencyProperty ValueProperty
Identifies the Value dependency property.