Skip to content

VisualStateGroup.Name and VisualState.Name return null instead of an empty string when unnamed #25370

Open

Description

@MartinZikmund

Current behavior 🐛

VisualStateGroup.Name (and VisualState.Name) returns null for an unnamed group/state. WinUI returns an empty string.

On master, VisualStateGroup.Name is public string Name { get; internal set; } with no default and no null normalization (src/Uno.UI/UI/Xaml/VisualStateGroup.cs), and VisualState.Name is a plain { get; set; }. ToString() and the logging code already special-case the null.

Code that compares or concatenates names sees null instead of "". Impact is small. A third-party library hit it as a failing test asserting string.Empty after the setter became internal.

Expected behavior 🎯

An unnamed VisualStateGroup / VisualState has Name == "".

Backed by the WinUI C++ sources: both getters read the DependencyObject_Name property through GetValue and return the HSTRING value, whose default is empty:

  • VisualStateGroup::get_NameImpl in dxaml/xcp/dxaml/lib/VisualStateGroup_Partial.cpp
  • VisualState::get_NameImpl in dxaml/xcp/dxaml/lib/visualstate.cpp

This was not checked with a native WinUI run.

How to reproduce it 🔬

  1. Reference Uno.WinUI built from master in any app.
  2. Run:
var group = new VisualStateGroup();
var state = new VisualState();
Debug.Assert(group.Name == string.Empty); // Uno: null
Debug.Assert(state.Name == string.Empty); // Uno: null

Confirmed by code inspection of master (0599dad), not by a new runtime test. The same assertion for the group failed in a downstream library's runtime tests on WebAssembly.

Workaround 🛠️

Treat null as empty, or set the name via the public Uno.UI.Helpers.MarkupHelper.SetXName(group, string.Empty).

Works on UWP/WinUI

Yes

Environment

Uno.WinUI 7.0.0-dev / master 0599dad, net10.0

Affected platforms

Skia (all heads), WebAssembly (observed)

Anything else

A fix is in progress in #25184 (declares Name on DependencyObject like WinUI and coerces null to ""). Related: #25346, #25213, #21129.

Activity

  1. added
    kind/bug
    triage/untriaged
    project/styling 👔
    platform/all
    difficulty/starter 🚀
    on Oct 12, 2026
  2. removed
    triage/untriaged
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty/starter 🚀kind/bugplatform/allproject/styling 👔

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions