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();
}
}
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.
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:
base.OnApplyTemplate()
. When code is run the breakpoint should be hit: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:
Using MUX no template is applied:
Also see above.
Version Info
NuGet package version:
Microsoft.UI.Xaml 2.4.3
This looks like WinUI3 vs the other issue is in WinUI2.x
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 https://github.com/microsoft/CsWinRT/issues/345
@StephenLPeters @stevenbrix I can't see solution for this issue in microsoft/CsWinRT#345 (Closed) or am i missing?
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.
Most helpful comment
This looks like WinUI3 vs the other issue is in WinUI2.x