Repository navigation
Description
Current behavior
The current precedences mechanism is not following its own logic, especially when applying values coming from default style (defined in generic.xaml), implicit style (keyless resolved through resource dictionaries) and explicit style (keyed style referenced directly on the element).
TLDR
The default style is always saved under the ImplicitStyle precedence and the applied style (implicit or explicit) is saved under the ExplicitStyle precedence.
Observed result
Building the following code:
public sealed partial class MyControl : Control
{
// Register a DependencyProperty "MyProperty" of type string
public static readonly DependencyProperty MyPropertyProperty
= DependencyProperty.Register("MyProperty", typeof(string), typeof(MyControl), new PropertyMetadata("Default Metadata Value")
);
public string MyProperty
{
get => (string)GetValue(MyPropertyProperty);
set => SetValue(MyPropertyProperty, value);
}
public MyControl()
{
DefaultStyleKey = typeof(MyControl);
MyProperty = "Local Value";
}
}In generic.xaml:
<Style TargetType="local:MyControl">
<Setter Property="MyProperty" Value="Default from Generic.xaml" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:MyControl">
<TextBlock Text="{TemplateBinding MyProperty}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>In app.xaml (AppResources.xaml)
<Style TargetType="local:MyControl" x:Key="MyControlStyle">
<Setter Property="MyProperty" Value="Explicit Style Value" />
</Style>
<Style TargetType="local:MyControl" x:Key="MyControlImplicitStyle">
<Setter Property="MyProperty" Value="Implicit Style Value" />
</Style>
<Style TargetType="local:MyControl" BasedOn="{StaticResource MyControlImplicitStyle}" />Used like that in the MainPage.xaml:
<StackPanel
HorizontalAlignment="Left"
VerticalAlignment="Center"
Padding="100, 20"
Spacing="20">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="NormalState" />
<VisualState x:Name="AlteredState">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="my" Storyboard.TargetProperty="MyProperty">
<DiscreteObjectKeyFrame KeyTime="0" Value="Value from VisualStateManager" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<local:MyControl x:Name="my" MyProperty="XAML Value (explicit)" Style="{StaticResource MyControlStyle}" />
<TextBlock x:Name="result"></TextBlock>
</StackPanel>Observed Result
| Precedence | Observed Value |
|---|---|
| Coercion | (unset) |
| FillingAnimations | (unset) |
| Animations | Value from VisualStateManager |
| Local | XAML Value (explicit) |
| TemplatedParent | (unset) |
| ExplicitStyle | Explicit Style Value |
| ImplicitStyle | Default from Generic.xaml |
| Inheritance | (unset) |
| DefaultStyle | (unset) |
| DefaultValue | Default Metadata Value |
Expected behavior
Expected Result
| Precedence | Observed Value |
|---|---|
| Coercion | (unset) |
| FillingAnimations | (unset) |
| Animations | Value from VisualStateManager |
| Local | XAML Value (explicit) |
| TemplatedParent | (unset) |
| ExplicitStyle | Explicit Style Value |
| ImplicitStyle | Implicit Style Value (!!) |
| Inheritance | (unset) |
| DefaultStyle | Default from Generic.xaml (!!) |
| DefaultValue | Default Metadata Value |
How to reproduce it (as minimally and precisely as possible)
No response
Workaround
No response
Works on UWP/WinUI
No
Environment
Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
NuGet package version(s)
Uno 5.1
Affected platforms
WebAssembly, Android, iOS, macOS (AppKit), Mac Catalyst, Skia (WPF), Skia (GTK on Linux/macOS/Windows), Skia (Linux Framebuffer)
IDE
No response
IDE version
No response
Relevant plugins
No response
Anything else we need to know?
No response
Activity
Youssef1313 commentedon Apr 18, 2024
Yup. We're taking this as a breaking change in Uno 6. See #15684
There shouldn't be any bugs caused by this though. Just wrong terminology being used.
Note that the precedences enum isn't intended for public access, even if it's public.
[-]DependencyProperties precedences storage is wrong[/-][+]`DependencyProperties` precedences storage is wrong[/+]github-actions commentedon May 3, 2026
This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.
refactor(dp)!: Clean up DependencyPropertyValuePrecedences enum
refactor(dp)!: Clean up DependencyPropertyValuePrecedences enum
MartinZikmund commentedon Aug 3, 2026
Audit result: DONE in
feature/breakingchanges(as of43acbf69dd).DependencyPropertyValuePrecedenceshas been realigned onto WinUI'sBaseValueSourcemodel, so the mismatch described here — the default style stored underImplicitStyleand the applied style stored underExplicitStyle— no longer exists. The fix intentionally does not implement the "Expected behavior" table verbatim; see the scope note below.src/Uno.UI/UI/Xaml/DependencyPropertyValuePrecedences.csnow declaresCoercion, Animations, Local, Style, BuiltInStyle, Inheritance, DefaultValue.ExplicitStyle→Style(WinUIBaseValueSourceStyle),ImplicitStyle/DefaultStyle→ a singleBuiltInStyle(WinUIBaseValueSourceBuiltInStyle), and the reader-lessTemplatedParentlevel was removed.BuiltInStylenow sits aboveInheritance, documented in the XML remarks on the member.DependencyObjectStore.cs:2227/2233/2263,FrameworkElement.cs:515and:687,Style/Style.cs:128-180,Internal/DependencyPropertyHelper.cs:169-176,DependencyObjectExtensions.cs:415-417,WrapPanel.cs:17,Slider.mux.cs:693,SampleControl.cs:64. Grepping the branch forPrecedences.ExplicitStyle|ImplicitStyle|DefaultStyle|TemplatedParentreturns no code hits.Stylelevel, because WinUI'sBaseValueSourcehas no such split (PropertySystem.cpp/PropertyChainEvaluator.cppexpose onlyBaseValueSourceStyleandBaseValueSourceBuiltInStyleand handle them identically), andFrameworkElement.UpdateActiveStyle()applies exactly one style. That matches @Youssef1313's triage above — wrong terminology, not a behavioural bug.build/PackageDiffIgnore.xml:2312-2315records all four removed members (TemplatedParent,ExplicitStyle,ImplicitStyle,DefaultStyle), each with a#16356reason.src/Uno.UI.UnitTests/DependencyProperty/Given_DependencyProperty.csaddsWhen_Each_Precedence_Set_Then_Highest_Wins(line 434) andWhen_BuiltInStyle_Set_Then_Takes_Precedence_Over_Inherited_Value(line 468); the runtime testGiven_DependencyPropertyHelper.cs:223assertsPrecedences.Style.Fixed by #23685
Cosmetic follow-up only, no functional impact: two comments still name removed members —
src/Uno.UI/UI/Xaml/Documents/TextElement.cs:388andsrc/Uno.UI.UnitTests/DependencyProperty/Given_DependencyProperty.cs:1765. Also note the PR targetedfeature/breakingchanges, so itscloses #16356will not auto-close this issue — it needs a manual close.Audit is code inspection against the branch worktree; no build or runtime validation was performed.
[-]`DependencyProperties` precedences storage is wrong[/-][+]`DependencyProperties` precedences storage is wrong [7.0 ][/+][-]`DependencyProperties` precedences storage is wrong [7.0 ][/-][+]`DependencyProperties` precedences storage is wrong [7.0][/+]MartinZikmund commentedon Aug 27, 2026
Audit result: DONE in
feature/breakingchanges(as of0950717a0d7).Re-verified against the current tip; every claim in the 2026-08-13 audit round still holds byte-for-byte — same line numbers, same enum shape, same write/read sites, same tests.
DependencyPropertyValuePrecedencesis realigned onto WinUI'sBaseValueSourcemodel, so the mismatch described in the issue — the default style stored underImplicitStyleand the applied style stored underExplicitStyle— no longer exists.Landed
src/Uno.UI/UI/Xaml/DependencyPropertyValuePrecedences.cs:7-46declaresCoercion, Animations, Local, Style, BuiltInStyle, Inheritance, DefaultValue.ExplicitStyle→Style(documented<remarks>Corresponds to WinUI's <c>BaseValueSourceStyle</c>.</remarks>at:27),ImplicitStyle/DefaultStyle→ a singleBuiltInStyle(:32-37,Corresponds to WinUI's BaseValueSourceBuiltInStyle), and the reader-lessTemplatedParentlevel is gone entirely.BuiltInStyle(ordinal 4) sits aboveInheritance(ordinal 5) in declaration order, with the XML remarks at:34-36explicitly stating "This takes precedence over inherited property values so that setters not covered by an applied style are still honored" — the(!!)row from the issue's expected table.src/Uno.UI/UI/Xaml/FrameworkElement.cs:493writes the applied style (explicit or implicit) atDependencyPropertyValuePrecedences.Style(OnStyleChanged(oldActiveStyle, _activeStyle, DependencyPropertyValuePrecedences.Style));FrameworkElement.cs:665writes the Generic.xaml default style atDependencyPropertyValuePrecedences.BuiltInStyleinsideApplyDefaultStyle().grep -rn "Precedences\.\(ExplicitStyle\|ImplicitStyle\|DefaultStyle\|TemplatedParent\)" src/returns 0 hits anywhere insrc/.build/PackageDiffIgnore.xml:2397-2398(and surrounding block) records the removed/renamed members with#16356reasons, e.g.<Member fullName="Microsoft.UI.Xaml.DependencyPropertyValuePrecedences Microsoft.UI.Xaml.DependencyPropertyValuePrecedences::TemplatedParent" reason="Removed unused TemplatedParent precedence (#16356, breaking changes for 7.0)" />and theExplicitStyle→Stylerename entry immediately below it.src/Uno.UI.UnitTests/DependencyProperty/Given_DependencyProperty.cs:434(When_Each_Precedence_Set_Then_Highest_Wins) and:468(When_BuiltInStyle_Set_Then_Takes_Precedence_Over_Inherited_Value); runtime testsrc/Uno.UI.RuntimeTests/Tests/Uno_Helpers/Given_DependencyPropertyHelper.cs:223assertsprecedence.Should().Be(DependencyPropertyValuePrecedences.Style).Landed via #23685 (merge commit
004885fda6, confirmed an ancestor ofHEADviagit merge-base --is-ancestor 004885fda6 HEAD).Caveats (not blocking)
src/Uno.UI/UI/Xaml/Documents/TextElement.cs:385("we set this with ImplicitStyle precedence") andsrc/Uno.UI.UnitTests/DependencyProperty/Given_DependencyProperty.cs:1765("PropB should be on the ExplicitStyle value"). Cosmetic only — no code reads those literal names, confirmed by the zero-hit grep above; unchanged since the last audit round.feature/breakingchanges, so itscloses #16356never auto-closed this issue on GitHub; it was closed manually.Audit is code inspection against the branch worktree; no build or runtime validation was performed.