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

Subclassing ScrollView won't allow custom templates #10233

Open
dotMorten opened this issue Dec 13, 2024 · 0 comments
Open

Subclassing ScrollView won't allow custom templates #10233

dotMorten opened this issue Dec 13, 2024 · 0 comments
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners

Comments

@dotMorten
Copy link
Contributor

Describe the bug

I was trying to subclass ScrollView, and while that works fine, I'm not able to change DefaultStyleKey to my own style from Generic.xaml. When I set it to my own type, OnApplyTemplate is never called and the control fails to render.

Steps to reproduce the bug

  1. Either download and run sample app and skip to step 5: ScrollViewTemplateBug.zip
    or:
  2. Create a new templated control and inherit from ScrollView.
  3. Set the DefaultStyleKey to the type of the control
  4. Define a matching style in Generic.xaml (it can just be the default scrollview template with the type parameters changed).
  5. Run sample and observe OnApplyTemplate is not hit in the custom control (and attached sample renders the red background)
  6. Remove the "DefaultStyleKey" setter in the constructor and notice that OnApplyTemplate is not hit and the template from the ScrollView baseclass is applied instead (attached sample now renders green).

Expected behavior

The custom template is applied so that we can easily attach additional behavior to scrollview

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003

Windows version

Windows 11 (24H2): Build 26100

Additional context

No response

@dotMorten dotMorten added the bug Something isn't working label Dec 13, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

1 participant