Skip to content

Meter

Meter derives from native System.Windows.Controls.ProgressBar (NaviusMeter), restyled as a static, determinate readout rather than a progress operation: IsIndeterminate is coerced to always false, and Value is genuinely clamped into [Minimum, Maximum] by RangeBase’s own default coercion, unlike NaviusProgress’s deliberate “validate, don’t clamp” behavior.

xmlns:navius="clr-namespace:Navius.Wpf.Primitives.Controls;assembly=Navius.Wpf.Primitives"
<StackPanel>
<navius:NaviusMeterLabel x:Name="DiskLabel" Text="Disk usage" />
<navius:NaviusMeter x:Name="Disk"
Value="72"
Minimum="0"
Maximum="100"
AutomationProperties.LabeledBy="{Binding ElementName=DiskLabel}" />
<navius:NaviusMeterValue Source="{Binding ElementName=Disk}" />
</StackPanel>
Property Type Default From Description
Value double 0.0 ProgressBar (RangeBase) Current value, clamped into [Minimum, Maximum] by the inherited default coercion (no override).
Minimum double 0.0 ProgressBar (RangeBase) Minimum value.
Maximum double 100.0 NaviusMeter (overrides RangeBase) A value <= Minimum falls back to Minimum + 100.
IsIndeterminate bool false (locked) NaviusMeter (overrides ProgressBar) Always coerced to false; setting it true is silently rejected. Meter is contractually always a static, determinate readout.
GetValueLabel Func<double, string?>? null NaviusMeter Builds the value text for the current value. Defaults to the rounded percentage plus "%".
Fraction double computed NaviusMeter Read-only, not a DP. 0..1, min-aware: (Value - Minimum) / (Maximum - Minimum).
Percentage double computed NaviusMeter Read-only, not a DP. Fraction * 100.
Source NaviusMeter? null NaviusMeterValue The meter instance whose formatted value text this element renders.
TextOverride string? null NaviusMeterValue When set, overrides the default rounded-percentage text.
Method Description
FormatValueText() Returns GetValueLabel or the default rounded percentage plus "%". Always non-null (unlike NaviusProgress.FormatValueText()), since Meter is never indeterminate.
Event Signature Fires when
StateChanged RoutedEventHandler Value, Minimum, or Maximum changes; consumed by NaviusMeterValue to refresh its text.

NaviusMeterAutomationPeer (derives ProgressBarAutomationPeer) overrides GetItemStatusCore() to return FormatValueText(), mirroring NaviusProgressAutomationPeer. AutomationControlType stays the inherited ProgressBar value, since WPF has no distinct Meter automation type; this is an acknowledged platform gap, not an attempt to spoof a different control type. The inherited ProgressBarAutomationPeer’s IRangeValueProvider is already read-only (SetValue throws), matching the contract’s “no keyboard, no focus management.” The unit suite covers the clamping behavior (Value_IsClampedIntoRange_UnlikeProgress, Value_Negative_IsClampedToMinimum), the IsIndeterminate lock (IsIndeterminate_AlwaysCoercedToFalse), the Maximum <= Minimum fallback, default values, and the automation peer’s ItemStatus text.

  • Value is genuinely clamped into [Minimum, Maximum] via RangeBase’s own default CoerceValueCallback (no override needed), the opposite choice from NaviusProgress’s “validate, don’t clamp” deviation.
  • IsIndeterminate is locked to false via a CoerceValueCallback override, so the indeterminate-pulse visual/behavior from NaviusProgress is unreachable here; this also resolves the parity doc’s own concern about a screen reader announcing a static Meter as an active progress operation.
  • Maximum <= Minimum falls back to Minimum + 100 (Meter’s own rule, distinct from Progress’s Maximum <= 0 -> 100).
  • GetValueLabel is Func<double, string?>? (single parameter), matching the web contract exactly; no deviation here, unlike NaviusProgress’s two-parameter signature.
  • AutomationControlType has no distinct “Meter” UIA value and stays the inherited ProgressBar value; disclosed platform gap, not a false claim.
  • aria-labelledby wiring uses the same AutomationProperties.LabeledBy idiom as NaviusProgress, not a push-based context registration.

The Meter Gallery page rendered at the pinned commit, in each theme.

Meter Gallery page in the light theme

Meter Gallery page in the dark theme

Meter Gallery page in the high contrast theme