Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom style is not applied #3499

Closed
Vinothini-V opened this issue Oct 27, 2020 · 5 comments
Closed

Custom style is not applied #3499

Vinothini-V opened this issue Oct 27, 2020 · 5 comments
Labels
duplicate This issue or pull request already exists product-winui3 WinUI 3 issues

Comments

@Vinothini-V
Copy link

Describe the bug
I have a custom control derived from DropdownButton and have style for this control. But custom style is not applied.

Steps to reproduce the bug
public sealed class CustomControl1 : DropDownButton
{
public CustomControl1()
{
this.DefaultStyleKey = typeof(CustomControl1);
}

    protected override void OnApplyTemplate()
    {
        base.OnApplyTemplate();
    }
}
<Style x:Key="CCStyle" TargetType="local:CustomControl1"> </Style>
<Style TargetType="local:CustomControl1" BasedOn="{StaticResource CCStyle}"/>

Expected behavior
This custom style should be applied.

Version Info
NuGet package version: 3.0.0-preview2.200713.0

Windows app type:

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

Additional context
But for me when custom style is used OnApplyTemplate itself is not called. And it works well for controls derived from Button, ListView but not fro DropdownButton, SplitButton, TabView and NavigationView.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Oct 27, 2020
@robloo
Copy link
Contributor

robloo commented Oct 27, 2020

Since I can see my Bug report #3502 getting closed as duplicate :) I'm duplicating my report for a similar issue below:


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

@ranjeshj
Copy link
Contributor

This looks like WinUI3 vs the other issue is in WinUI2.x

@ranjeshj ranjeshj added the product-winui3 WinUI 3 issues label Oct 27, 2020
@stevenbrix
Copy link
Contributor

While these are similar, I agree with @ranjeshj that they are most likely different.

This particular issue, which is a WinUI3 one, seems like a dupe of microsoft/CsWinRT#345

@StephenLPeters StephenLPeters added duplicate This issue or pull request already exists and removed needs-triage Issue needs to be triaged by the area owners labels Oct 28, 2020
@jeganrajm
Copy link

@StephenLPeters @stevenbrix I can't see solution for this issue in microsoft/CsWinRT#345 (Closed) or am i missing?

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Oct 29, 2020
@StephenLPeters
Copy link
Contributor

It should be Fixed with CsWinRT1.0.1 which is included in Winui3 preview 3. so the issue should be resolved by upgrading to that when it becomes available.

@ghost ghost removed the needs-triage Issue needs to be triaged by the area owners label Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists product-winui3 WinUI 3 issues
Projects
None yet
Development

No branches or pull requests

6 participants