Skip to content

Name change callback isn't raised when the same name is written again (WinUI raises it) #25213

Open

Description

@MartinZikmund

Current behavior 🐛

A FrameworkElement.NameProperty change callback only fires when the name actually changes. Writing the same name again, or clearing a name that was never set, raises nothing.

Operation (callback via RegisterPropertyChangedCallback(FrameworkElement.NameProperty, ...)) WinUI Uno
border.Name = "A" three times 3 1
ClearValue(NameProperty) on an unset name 1 0
Style setter S, then local Name = "S", then ClearValue 3 1
VisualState setter writing A twice 2 1
Style setter on Name masked by a local Name = "L" 0 0 (already aligned)

Expected behavior 🎯

As in WinUI, every write of the effective value of DependencyObject_Name (exposed as FrameworkElement.NameProperty) raises the change notification, even when the value is unchanged. A write masked by a higher-precedence value doesn't notify.

How to reproduce it (as minimally and precisely as possible) 🔬

var border = new Border();
var count = 0;
border.RegisterPropertyChangedCallback(FrameworkElement.NameProperty, (s, dp) => count++);

border.Name = "A";
border.Name = "A";
border.Name = "A";

// WinUI: 3, Uno: 1

The same applies to non-FrameworkElement objects through SetValue(FrameworkElement.NameProperty, ...) once #25184 lands.

Workaround 🛠️

None needed for most apps. Code that relies on the callback for a same-value write must compare the value itself.

Affected platforms 📱💻🖥️

Skia (WebAssembly), Skia (Android), Skia (iOS), Skia (Linux X11), Skia (Linux Framebuffer), Skia (macOS), Skia (Windows)

Uno.Sdk version (and other relevant versions) 📦

master (7.0 development), efa29548ba2

IDE version 🧑‍💻

No response

Anything else we need to know? 💬

WinUI source:

  • CDependencyObject::SetEffectiveValue starts with propertyChangedValue = true ("assume we changed unless we detect otherwise"), dxaml/xcp/components/DependencyObject/PropertySystem.cpp:1538.
  • SetEffectiveValueInField stores DependencyObject_Name through SetName and never clears propertyChangedValue for it (PropertySystem.cpp:2137-2141). Compare the comment at :2112 on field-backed object values: "notification was always raised".
  • A write masked by a higher precedence never reaches SetEffectiveValue, so it doesn't notify.

Uno: DependencyObjectStore.RaiseCallbacks (src/Uno.UI/UI/Xaml/DependencyObject.Store.cs) invokes callbacks only when AreDifferent(newValue, previousValue).

Verified on WinUI with a WinAppSDK 2.4.0 oracle app. A prototype fix also passed: pass the write's precedence into RaiseCallbacks, and notify for DependencyObject_Name when precedence <= newPrecedence. It was split out of #25184 to keep DependencyObject.Store.cs unchanged there.

Activity

  1. added
    kind/bug
    triage/untriaged
    difficulty/medium 🤔
    on Oct 11, 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/medium 🤔kind/bugtriage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions