-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Merged
XAML-Knight
merged 4 commits into
CommunityToolkit:main
from
XAML-Knight:ListDetailsView_RemoveHardcoded
Jul 28, 2021
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
private Frame _frame; | ||
|
||
/// <summary> | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Love seeing the new visual tree extensions being useful! 🙌 |
||
_frame = this.FindAscendant<Frame>(); | ||
if (_frame != null) | ||
{ | ||
|
@@ -448,20 +448,11 @@ private void SetNavigationViewBackButtonState(int visible, bool enabled) | |
return; | ||
} | ||
|
||
var navType = _navigationView.GetType(); | ||
var visibleProperty = navType.GetProperty("IsBackButtonVisible"); | ||
if (visibleProperty != null) | ||
{ | ||
_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 commentThe reason will be displayed to describe this comment to others. Learn more. We can strongly type to the |
||
_navigationView.IsBackButtonVisible = (Microsoft.UI.Xaml.Controls.NavigationViewBackButtonVisible)visible; | ||
|
||
var enabledProperty = navType.GetProperty("IsBackEnabled"); | ||
if (enabledProperty != null) | ||
{ | ||
_previousNavigationViewBackEnabled = (bool)enabledProperty.GetValue(_navigationView); | ||
enabledProperty.SetValue(_navigationView, enabled); | ||
} | ||
_previousNavigationViewBackEnabled = _navigationView.IsBackEnabled; | ||
_navigationView.IsBackEnabled = enabled; | ||
} | ||
|
||
private void SetDetailsContent() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: