Skip to content

ContentPresenter should fall back to Content when value is not available #19649

Open
@MartinZikmund

Description

@MartinZikmund

Current behavior

AppBarButton has the following in the template:

<ContentPresenter x:Name="Content" Content="{TemplateBinding Icon}" Foreground="{TemplateBinding Foreground}" />

When Icon is not set, it magically falls back to parent's Content instead. Compare:

Image

See ContentPresenter.cpp:

pdpTarget = GetPropertyByIndexInline(KnownPropertyIndex::ContentPresenter_Content);
            IFCEXPECT(pdpTarget);
            if (IsPropertyDefault(pdpTarget) && !IsPropertyTemplateBound(pdpTarget))
            {
                const CDependencyProperty* pdpSource = pTemplatedParent->GetPropertyByIndexInline(KnownPropertyIndex::ContentControl_Content);
                IFCEXPECT(pdpSource);

                IFC(SetTemplateBinding(pdpTarget, pdpSource));
                needsRefresh = true;
            }

Expected behavior

No response

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

No response

Workaround

No response

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

difficulty/tbdCategorizes an issue for which the difficulty level needs to be defined.kind/bugSomething isn't workingtriage/untriagedIndicates an issue requires triaging or verification

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions