Winui2 should have tests which ensure that code behind does not require template parts.
See original GitHub issueWas 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:
- Created 2 years ago
- Comments:11 (8 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?
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.