ButtonGroup
Overview
Section titled “Overview”ButtonGroup is a segmented button row: an ItemsControl whose children are
NaviusButtonGroupItem instances placed directly by the consumer, a plain UIElement collection
like a StackPanel’s Children, not a data-bound ItemsSource. Every item renders as a plain
square segment; the single rounded silhouette comes from a Grid.Clip on the group’s own
container (a RoundedClipConverter multi-binding reading the container’s live size and its
CornerRadius token), not from per-item corner math. Each item still needs to know whether it is
the last one in its Orientation, so its own trailing edge grows a second hairline border
(every other item’s single border already becomes the shared divider with its next sibling).
xmlns:buttonGroup="clr-namespace:Navius.Wpf.Ui.ButtonGroup;assembly=Navius.Wpf.Ui"
<buttonGroup:NaviusButtonGroup> <buttonGroup:NaviusButtonGroupItem Content="Cut" /> <buttonGroup:NaviusButtonGroupItem Content="Copy" /> <buttonGroup:NaviusButtonGroupItem Content="Paste" /></buttonGroup:NaviusButtonGroup>Properties
Section titled “Properties”| Property | Type | Default | From | Description |
|---|---|---|---|---|
Orientation |
System.Windows.Controls.Orientation |
Horizontal |
NaviusButtonGroup |
Direction of the segment row; inherits down to descendants (FrameworkPropertyMetadataOptions.Inherits) so the border-mask trigger can read it from any item. |
Items |
ItemCollection |
empty | ItemsControl (NaviusButtonGroup) |
Populated directly with NaviusButtonGroupItem instances. |
Content |
object |
- |
ContentControl (NaviusButtonGroupItem, via ButtonBase) |
The segment’s label. |
An attached, read-only IsLastItem boolean (NaviusButtonGroup.GetIsLastItem) is stamped onto
each item by the group itself, not set by the consumer; it drives the border-thickness triggers
in Themes/ButtonGroup.xaml that add the trailing hairline only on the last segment of each
orientation.
Methods
Section titled “Methods”| Method | Description |
|---|---|
NaviusButtonGroup.IsLast(index, count) |
Pure position computation (index == count - 1, false when count <= 0), split out for direct unit testing without a container generator. |
NaviusButtonGroup.GetIsLastItem(DependencyObject) |
Reads the attached, read-only IsLastItem value stamped on a realized item container. |
UIA mechanism
Section titled “UIA mechanism”Neither NaviusButtonGroup nor NaviusButtonGroupItem overrides OnCreateAutomationPeer.
NaviusButtonGroup falls back to ItemsControl’s own peer, ItemsControlAutomationPeer,
reporting AutomationControlType.List. NaviusButtonGroupItem derives directly from
ButtonBase rather than Button (so it can carry its own template without the NaviusButton
primitive’s hardcoded corner radius), and ButtonBase itself does not supply an automation peer;
only concrete subclasses such as Button do. As shipped, NaviusButtonGroupItem therefore has no
automation peer at all: it reports no Invoke pattern and no Button control type to UIA. The
unit suite covers the position math (ButtonGroup_IsLast_*) and container stamping
(ButtonGroup_PrepareContainer_StampsIsLastItem in tests/Navius.Wpf.Tests/UiCompositeTests.cs),
not an automation surface. The M6 audit found the RoundedClipConverter multi-binding clean
(inherently one-way, no template-part lookup, no animation).
Web deltas
Section titled “Web deltas”NaviusButtonGroupItemderives fromButtonBasedirectly instead of theNaviusButtonprimitive, because it needs its own template rather than the primitive’s hardcoded full-radius corner treatment; the group’s outer clip supplies the rounding instead.