question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Winui2 should have tests which ensure that code behind does not require template parts.

See original GitHub issue

Was NavigationView crashes if PaneTitleOnTopPane is not in the control template

Describe the bug

If a custom template is used for NavigationView and the TextBlock with x:Name="PaneTitleOnTopPane" is not present, the control fails to load.

Steps to reproduce the bug

Create custom template and remove PaneTitleOnTopPane.

Expected behavior

Should not crash

Screenshots

Version Info

NuGet package version: 2.6.1

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (22200) Yes
October 2020 Update (19042)
May 2020 Update (19041)
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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
michael-hawkercommented, Jul 28, 2021

I know this specific issue has been resolved, but I don’t think there’s a general tracking issue for improving this across the repo, eh?

1reaction
StephenLPeterscommented, Jul 27, 2021

The best way to test would to just be blank out all the styles from all controls and then try and load them, right? Though I suppose you could have cascades, where a component is only looked at if another exists…

It should catch at least some though…

Yes, I think this would be pretty easy and catch the majority of cases.

@mrlacey its not as simple as named element means the code behind requires the element. Sometimes we name an element simply to reference it other places in the template with Bindings or with Setters. This means that some of the suggestions you had would be too restrictive as there are valid scenarios for deleting named template parts.

Even if a template part is used by code behind to wire something up, it can still be valid to delete that template part, and the code should be resilient to that.

I definitely agree this is a place we could really improve the framework.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content Dialog is not resilient to template changes which ...
Awesome, sounds like we've identified a real issue in Content Dialog's code behind. It should be resilient to missing template parts. We can...
Read more >
Teaching tips - Windows apps
A teaching tip is a semi-persistent and content-rich flyout that provides contextual information.
Read more >
get_template_part() | Function
Provides a simple mechanism for child themes to overload reusable sections of code in the theme. Includes the named template part for a...
Read more >
Migrating the authentication UI
The first part of this code ensures that the user has entered a username and password - if not, an error message from...
Read more >
What is Actually the Universal Windows Platform and what ...
For new UWP apps, you should use the “WinUI in UWP” project template that creates a UWP application that uses the UWP XAML...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found