Skip to content

Avatar

Avatar (NaviusAvatar) is a single lookless Control folding the web contract’s three parts (Root/Fallback/Image) into one ControlTemplate that overlays a named PART_Image Image over a fallback region, switching visibility off a Status dependency property. Status (Idle/ Loading/Loaded/Error) is driven internally by Source changes and BitmapImage download events, and an optional DelayMs window suppresses the fallback from flashing during a fast load.

xmlns:navius="clr-namespace:Navius.Wpf.Primitives.Controls;assembly=Navius.Wpf.Primitives"
<navius:NaviusAvatar Source="https://example.com/avatar.png" DelayMs="200">
<navius:NaviusAvatar.Fallback>
<TextBlock Text="LZ" />
</navius:NaviusAvatar.Fallback>
</navius:NaviusAvatar>
Property Type Default From Description
Source string? null NaviusAvatar Image URI/path. A (re)assigned non-empty value transitions Status to Loading until resolved via the BitmapImage download or the template Image’s ImageFailed.
DelayMs int 0 NaviusAvatar If <= 0, the fallback may render immediately; otherwise it waits DelayMs before the fallback is allowed to show.
Fallback object? null NaviusAvatar Content shown while IsFallbackVisible is true.
Status NaviusAvatarLoadStatus Idle NaviusAvatar Current load status (Idle/Loading/Loaded/Error). Normally driven internally by Source/image events; exposed as a public, settable dependency property (a deliberate deviation from the web’s internal-only status) for template triggers and tests.
IsFallbackVisible bool true NaviusAvatar Read-only. True when Status != Loaded and the DelayMs window (if any) has elapsed.
Event Signature Fires when
LoadingStatusChanged RoutedPropertyChangedEventHandler<NaviusAvatarLoadStatus> Status transitions to a new value.

NaviusAvatar.cs has no OnCreateAutomationPeer() override, so no custom automation peer is created for this control; the web contract also wires no ARIA role or aria-* attribute on any Avatar part, so no specific UIA control-type parity is owed. Note: the parity doc’s own “WPF strategy” section proposed mapping the composite to an explicit FrameworkElementAutomationPeer (“plain ContentControl-level automation is sufficient”), but the shipped code does not add one; this is a parity-doc-vs-code gap worth flagging rather than a verified fact about the family’s runtime automation representation.

  • The web’s three parts (NaviusAvatar/NaviusAvatarFallback/NaviusAvatarImage) fold into one lookless Control with a single named template part (PART_Image), not three separate CLR types.
  • Status is exposed as a public, settable dependency property, unlike the web’s internal-only AvatarContext.Status setter.
  • Load-state wiring is BitmapImage.DownloadCompleted/DownloadFailed plus the template Image’s ImageFailed routed event, the WPF async-image analog of the web’s native onload/onerror; WPF has no literal “ImageOpened” event, so DownloadCompleted stands in for it. A synchronous resolve (e.g. a pack/file URI with no async download) sets Status = Loaded directly when bitmap.IsDownloading is already false after EndInit().
  • No data-state/status attribute is rendered anywhere in the web family either; the WPF port likewise adds no extra state marker beyond Status itself.

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

Avatar Gallery page in the light theme

Avatar Gallery page in the dark theme

Avatar Gallery page in the high contrast theme