Introducing a new way to review your PRs.

Read the announcement

huynhsontung / screenbox

LibVLC-based media player for the Universal Windows Platform

View on GitHub

19 documents · Updated Nov 23, 2026

docs / ui-controls-and-theming

UI controls and theming

Screenbox.UI is the shared UI project for the application shell. It gives pages a common set of controls and visual resources for navigation, window chrome, empty states, commands, split actions, keyboard input, animation, and accessibility. The application shell consumes these controls so that page code can focus on product content rather than repeat shell behavior.

Shared UI role

The shared UI project runs on UWP XAML and Microsoft UI XAML. Its resources are loaded through a common resource dictionary, which makes the same control styles and theme values available to the application shell and its pages. Screenbox.UI/Screenbox.UI.csproj

The project separates reusable behavior from visual resources. Control classes expose the public behavior, while templates and theme dictionaries define how that behavior appears in light, dark, default, and high-contrast modes. This split lets a control keep one user-facing contract while its visual treatment changes with the active theme. Screenbox.UI/Themes/Generic.xaml

Reusable controls

The controls extend standard shell controls where the application needs a shared interaction or layout rule. They preserve the base control model, then add a small number of properties for the application’s common needs.

NavigationViewEx provides the shell’s navigation frame with an overlay layer, independent content visibility, button styles, access keys, keyboard accelerators, and optional content motion. The overlay can sit over the main content while the pane remains usable, which supports shell experiences such as search or transient tools. Screenbox.UI/…/NavigationViewEx.cs Screenbox.UI/…/NavigationViewEx.Properties.cs

The control keeps navigation actions usable across mouse, keyboard, and game controller input. Its built-in pane, search, back, close, and settings actions can each receive access keys or keyboard accelerators. Screenbox.UI/…/NavigationViewEx.Properties.cs Screenbox.UI/…/NavigationViewEx.Properties.cs

References: Screenbox.UI/…/NavigationViewEx.cs• L26-41 Screenbox.UI/…/NavigationViewEx.cs• L184-255 Screenbox.UI/…/NavigationViewEx.Properties.cs• L15-79

Title bar

TitleBar replaces the system title bar with an application-owned area that can contain a title, icon, header, main content, and footer. It also keeps the window drag region, system caption buttons, window activation state, and right-to-left insets aligned with that custom area. Screenbox.UI/…/TitleBar.cs Screenbox.UI/…/TitleBar.cs

The title bar supports standard and tall layouts. Its theme values also control caption button colors and title contrast when the window is active or inactive, so window chrome follows the rest of the application theme. Screenbox.UI/…/TitleBarHeightMode.cs Screenbox.UI/Controls/TitleBar/TitleBar_themeresources.xaml

References: Screenbox.UI/…/TitleBar.cs• L102-156 Screenbox.UI/…/TitleBar.cs• L177-215 Screenbox.UI/…/TitleBar.xaml• L21-180

Unavailable content view

ContentUnavailableView presents a consistent empty or unavailable state instead of leaving a page blank. It can show an optional visual, title, message, and action content, then open or close as the page state changes. Screenbox.UI/…/ContentUnavailableView.Properties.cs

The control changes its visual states as each part becomes available. This allows a page to use the same view for a simple message or for a richer state with an icon and an action. Screenbox.UI/…/ContentUnavailableView.cs Screenbox.UI/Controls/ContentUnavailableView/ContentUnavailableView.xaml

References: Screenbox.UI/…/ContentUnavailableView.cs• L9-16 Screenbox.UI/…/ContentUnavailableView.cs• L106-175 Screenbox.UI/…/ContentUnavailableView.xaml• L8-140

Command and split controls

CommandBarEx and SplitButtonEx keep command surfaces consistent when a base control does not expose enough control over its internal buttons. A command bar can style its overflow button, while a split button can give its primary and secondary actions separate names, tooltips, and keyboard access. Screenbox.UI/…/CommandBarEx.cs Screenbox.UI/…/SplitButtonEx.cs

The split button also supports keyboard or game controller focus on its secondary action. Its templates provide the visual states for normal, hover, pressed, checked, disabled, and flyout-open conditions, so the two actions remain clear as state changes. Screenbox.UI/…/SplitButtonEx.Properties.cs Screenbox.UI/Controls/CommonStyles/SplitButton_themeresources.xaml

References: Screenbox.UI/…/CommandBarEx.cs• L27-91 Screenbox.UI/…/SplitButtonEx.cs• L44-203 Screenbox.UI/…/SplitButtonEx.Properties.cs• L7-111

Interaction behaviors

The shared controls connect public properties to the parts inside their templates. This makes behavior such as visibility, focus, keyboard input, animation, and flyout state work in the same way wherever the control is used.

Visual states and triggers

Visual states are the shared language between a control’s behavior and its template. A property change selects a state such as visible, collapsed, activated, deactivated, pressed, checked, or flyout open. The template then changes layout, color, focus treatment, or visibility without requiring each page to manage those details. Screenbox.UI/…/TitleBar.cs Screenbox.UI/…/ContentUnavailableView.cs

The templates use setters and theme resources as state outputs. This keeps state changes local to the control and allows the same behavior to use different colors or sizes for each theme. Screenbox.UI/Controls/TitleBar/TitleBar.xaml Screenbox.UI/Controls/ContentUnavailableView/ContentUnavailableView.xaml

References: Screenbox.UI/…/TitleBar.cs• L246-334 Screenbox.UI/…/ContentUnavailableView.cs• L106-159 Screenbox.UI/…/SplitButton_themeresources.xaml• L209-399

Keyboard and focus behavior

Keyboard behavior is part of the control contract rather than a page-specific add-on. Navigation controls expose access keys and accelerators for shell actions, and split buttons can place the secondary action in the tab sequence when that action must be reachable as a separate target. Screenbox.UI/…/NavigationViewEx.Properties.cs Screenbox.UI/…/SplitButtonEx.Properties.cs

The controls also map gamepad input to shell actions where needed. For example, the navigation view opens its pane and focuses search for the gamepad Y button, which keeps search reachable without a pointer. Screenbox.UI/…/NavigationViewEx.cs

References: Screenbox.UI/…/NavigationViewEx.cs• L159-181 Screenbox.UI/…/NavigationViewEx.cs• L395-497 Screenbox.UI/…/SplitButtonEx.cs• L121-203

Flyout behavior

Flyouts are supported as an action surface for controls rather than as a separate shared dialog system. SplitButtonEx accepts a flyout for the secondary action, and its visual states show that the action remains pressed while the flyout is open. Screenbox.UI/…/SplitButtonEx.cs Screenbox.UI/Controls/CommonStyles/SplitButton_themeresources.xaml

The shared UI project does not define a reusable dialog control in this area. Dialogs that need application-specific content remain outside this shared control set, while flyout styling belongs to the control template that owns the action. Screenbox.UI/Screenbox.UI.csproj

References: Screenbox.UI/…/SplitButtonEx.cs• L21-32 Screenbox.UI/…/SplitButton_themeresources.xaml• L209-230 Screenbox.UI/…/Generic.xaml• L6-19

Templates and theme resources

Templates define the visual contract for each reusable control. Theme resources define values that can change with system appearance or accessibility settings, while the generic dictionary makes the templates available to the application.

Resource dictionaries

Generic.xaml is the entry point for control resources. It merges the platform control resources with the shared templates for unavailable content and the title bar, then applies the shared command bar style. Screenbox.UI/Themes/Generic.xaml

XamlControlsResources gathers common styles, converter instances, and control theme resources into one dictionary. The title bar dictionaries include default, light, and high-contrast values, so a control can use ThemeResource lookups without duplicating theme selection logic. Screenbox.UI/Controls/XamlControlsResources.xaml Screenbox.UI/Controls/TitleBar/TitleBar_themeresources.xaml

References: Screenbox.UI/…/Generic.xaml• L1-19 Screenbox.UI/…/XamlControlsResources.xaml• L1-20 Screenbox.UI/…/TitleBar_themeresources.xaml• L6-86

Layout converters

ThicknessFiltersConverter lets a template reuse only selected sides of a margin or border thickness. Shared converter resources provide common left, right, top, bottom, horizontal, vertical, and combined filters for control templates. Screenbox.UI/…/ThicknessFiltersConverter.cs Screenbox.UI/Controls/CommonStyles/Thickness_themeresources.xaml

This keeps one source thickness usable by several visual parts. Split button templates use the filters to give the left side, divider, and right side the correct border and corner treatment without changing the public control properties. Screenbox.UI/Controls/CommonStyles/SplitButton_themeresources.xaml

References: Screenbox.UI/…/ThicknessFiltersConverter.cs• L56-116 Screenbox.UI/…/ThicknessFilterKinds.cs• L5-54 Screenbox.UI/…/Thickness_themeresources.xaml• L6-24

Motion resources

Motion is used to show changes in pane and content visibility without changing the control’s purpose. NavigationViewEx applies fade and translation motion to the pane and content when visibility or navigation display mode changes. Screenbox.UI/…/NavigationViewEx.cs Screenbox.UI/…/NavigationViewEx.cs

The motion settings are part of the shared behavior, so pages that use the extended navigation view receive the same transition pattern. The page still controls whether content is visible and which direction content moves. Screenbox.UI/…/NavigationViewEx.Properties.cs Screenbox.UI/…/NavigationViewEx.Properties.cs

References: Screenbox.UI/…/NavigationViewEx.cs• L74-87 Screenbox.UI/…/NavigationViewEx.cs• L280-297 Screenbox.UI/…/NavigationViewEx.cs• L544-579

Accessibility and automation

The shared controls expose meaningful control types and state changes to Microsoft UI Automation. This gives assistive tools a stable view of shell chrome and unavailable content even when the visual template changes.

Automation peers

An automation peer is the accessibility-facing object for a XAML control. TitleBar identifies itself as a title bar and supplies a useful name from its title or the package name, while ContentUnavailableView identifies itself as a status area. Screenbox.UI/…/TitleBarAutomationPeer.cs Screenbox.UI/…/ContentUnavailableViewAutomationPeer.cs

When unavailable content opens, the control raises an automation notification that combines its title and message. The control changes its accessibility view when closed, so hidden placeholder content does not remain in the active control tree. Screenbox.UI/…/ContentUnavailableView.cs Screenbox.UI/…/ContentUnavailableViewAutomationPeer.cs

References: Screenbox.UI/…/TitleBarAutomationPeer.cs• L20-46 Screenbox.UI/…/ContentUnavailableViewAutomationPeer.cs• L20-37 Screenbox.UI/…/ContentUnavailableView.cs• L106-123

Control and resource flow

The shared UI flow starts with a page or shell setting a public control property. The control maps that property to a template part or visual state, and the template resolves its appearance through shared theme resources.

This diagram shows how a shared control turns application state into themed and accessible UI.

flowchart LR
    A[Shell or page state] --> B[Public control property]
    B --> C[Control behavior]
    C --> D[Visual state or template part]
    D --> E[Theme resource]
    D --> F[Automation peer]
    E --> G[Rendered UI]
    F --> H[Assistive technology]

The same flow supports both simple content states and window-level behavior. A page can use a control without knowing how its internal parts are named, while the control remains responsible for keeping those parts and their accessibility state in sync. Screenbox.UI/Themes/Generic.xaml Screenbox.UI/…/ContentUnavailableView.cs

Change checklist

When these files or sections are changed, remember to consider these:

  • When a public control property changes, keep its template binding, visual state, and property-change response aligned.
  • When a template part is renamed, update the control behavior that connects to that part and check the related automation behavior.
  • When a theme resource key changes, update every template and default style that resolves that key through ThemeResource or StaticResource.
  • When navigation button behavior changes, review the matching access keys, keyboard accelerators, gamepad path, and button style properties.
  • When title bar layout changes, review the drag region, system insets, caption button colors, activation state, and reset behavior together.

Important failure modes

TriggerConsequenceGuard
A control template part name changes without a matching control updateThe control loses a button, drag region, overlay, or visibility update at run timeKeep template part names and the control’s template lookup contract aligned
A theme resource is removed or renamedA template can fail to load or fall back to the wrong visual valueTreat shared resource keys as contracts between theme dictionaries and templates
A content-unavailable view is updated while it is already openScreen readers do not receive a new open notification for the changed textClose and reopen the view when a new announcement is needed
A title bar is unloaded without restoring the system title barThe window can keep custom title bar settings after the control leaves the visual treePreserve the unload reset path when changing title bar lifetime behavior
A secondary split-button action stays out of the tab sequenceKeyboard or controller users cannot reach the flyout action as a separate targetSet IsSecondaryButtonTabStop when the secondary action needs independent focus

Key files

FileWhy to read it
Screenbox.UI/Themes/Generic.xamlShows how the shared control resources enter the application.
Screenbox.UI/Controls/XamlControlsResources.xamlShows the groups of common styles and theme resources.
Screenbox.UI/…/NavigationViewEx.csShows the shell navigation behavior, overlay handling, input, and motion.
Screenbox.UI/…/NavigationViewEx.Properties.csShows the navigation contract for overlays, visibility, styles, and input.
Screenbox.UI/…/TitleBar.csShows the relationship between custom title bar content and the system window.
Screenbox.UI/Controls/TitleBar/TitleBar.xamlShows the title bar template and its visual states.
Screenbox.UI/…/ContentUnavailableView.csShows empty-state behavior and accessibility notifications.
Screenbox.UI/Controls/ContentUnavailableView/ContentUnavailableView.xamlShows how optional empty-state parts become visible through template states.
Screenbox.UI/…/SplitButtonEx.csShows how the shared split control maps public behavior to its two actions.
Screenbox.UI/Controls/CommonStyles/SplitButton_themeresources.xamlShows the shared split-button states and flyout-open visuals.
Screenbox.UI/…/ThicknessFiltersConverter.csShows the small converter used to share layout values across templates.
Screenbox.UI/…/ContentUnavailableViewAutomationPeer.csShows how unavailable content reaches UI Automation.

Related pages: Application shell, Page navigation