Skip to content

Bug: Unable to Inherit from MUX WinUI 2.x Controls in C# #3502

@robloo

Description

@robloo

Describe the bug

Unable to create new controls inheriting from a MUX WinUI 2.x base control. The control template will never be applied.

Steps to reproduce the bug

Using the attached repro project below:

InheritTest.zip

  1. Using the WUX namespace set a breakpoint on base.OnApplyTemplate(). When code is run the breakpoint should be hit:
    image
  2. Change to the MUX namespace for the base control and run again with the same breakpoint:
    image
  3. The breakpoint in OnApplyTemplate() is never hit and the control template is never applied.

Note that if you change the DefaultStyleKey = typeof(ColorPicker) (the base type) that will work.

Expected behavior

It should be possible to inherit from a MUX WinUI 2.x base control and have the new control template applied.

Screenshots

Using WUX the template is correctly applied:
image

Using MUX no template is applied:
image

Also see above.

Version Info

NuGet package version:

Microsoft.UI.Xaml 2.4.3

Windows app type:

UWP Win32
Yes N/A
Windows 10 version Saw the problem?
Insider Build (xxxxx)
May 2020 Update (19041) Yes
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context

This is a pretty major roadblock. I need a work-around or fix pretty quickly...

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-NugetPackageIssue with the nuget package developer experience (e.g. build error, missing files)area-XamlCompilerbugSomething isn't workingneeds-winui-3Indicates that feature can only be done in WinUI 3.0 or beyond. (needs winui 3)product-winui3WinUI 3 issuesteam-ControlsIssue for the Controls teamteam-MarkupIssue for the Markup teamwct

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions