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
Update string reliance on WinUI NavigationView #4131
Update string reliance on WinUI NavigationView #4131
Conversation
Thanks XAML-Knight for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
Thanks @XAML-Knight, think there's other optimizations we can do now too as we can make the type on Line 50 an actual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works on the sample App. I also did a search for similar scenarios and did not find any.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Always feels good to see reflection code being removed! 🚀🚀🚀
@@ -199,7 +199,7 @@ private void OnLoaded(object sender, RoutedEventArgs e) | |||
_frame.Navigating -= OnFrameNavigating; | |||
} | |||
|
|||
_navigationView = this.FindAscendants().FirstOrDefault(p => p.GetType().FullName == "Microsoft.UI.Xaml.Controls.NavigationView"); | |||
_navigationView = this.FindAscendant<Microsoft.UI.Xaml.Controls.NavigationView>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love seeing the new visual tree extensions being useful! 🙌
_previousNavigationViewBackVisibilty = (int)visibleProperty.GetValue(_navigationView); | ||
visibleProperty.SetValue(_navigationView, visible); | ||
} | ||
_previousNavigationViewBackVisibilty = (int)_navigationView.IsBackButtonVisible; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can strongly type to the enum
value now over the int
here too. 🙂
@@ -47,7 +47,7 @@ public partial class ListDetailsView : ItemsControl | |||
private ContentPresenter _detailsPresenter; | |||
private VisualStateGroup _selectionStateGroup; | |||
private Button _inlineBackButton; | |||
private object _navigationView; | |||
private Microsoft.UI.Xaml.Controls.NavigationView _navigationView; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add a using at the top as well so we don't have to copy the namespace around:
using NavigationView = Microsoft.UI.Xaml.Controls.NavigationView;
Fixes #4127
Remove reliance upon hard-coded string
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Retrieves WinUI NavigationView by hard-coded string
What is the new behavior?
FindAscendant for NavigationView with WinUI namespace
PR Checklist
Please check if your PR fulfills the following requirements:
Other information