Skip to content

"The Name 'XXX' has already been defined" build error occurs if ControlTemplate has visual element and VisualState with the same names  #350

Closed
@pavelovcharov

Description

@pavelovcharov
  • .NET Core Version: 3.0.100-preview-010184
  • Windows version: 1809 (17763.253)
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: No

Problem description:
Build error occurs if ControlTemplate contains a visual element and VisualState with the same names

Actual behavior:
Build error "MC4101: The Name 'Normal' has already been defined. Names must be unique." occurs

Expected behavior:
No build errors

Minimal repro:
Create new .Net Core 3 wpf project, add the following ControlTemplate

    <Window.Resources>
        <ControlTemplate TargetType="Button" x:Key="buttonStyle">
            <Border x:Name="Normal">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="TestGroup">
                        <VisualState x:Name="Normal" />
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
            </Border>
        </ControlTemplate>
    </Window.Resources>

and try to build the project.

Metadata

Metadata

Assignees

Labels

BugProduct bug (most likely)Design DiscussionOngoing discussion about design without consensus

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions