更新整理
This commit is contained in:
@@ -3,13 +3,15 @@
|
||||
|
||||
/* Based on Windows UI Library */
|
||||
|
||||
using WPFluent.Abstractions;
|
||||
using WPFluent.Animations;
|
||||
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
|
||||
using System.Windows.Navigation;
|
||||
|
||||
using WPFluent.Abstractions;
|
||||
using WPFluent.Animations;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace WPFluent.Controls;
|
||||
|
||||
@@ -65,9 +67,9 @@ public class NavigationViewContentPresenter : Frame
|
||||
|
||||
public NavigationViewContentPresenter()
|
||||
{
|
||||
Navigating += static(sender, eventArgs) =>
|
||||
Navigating += static (sender, eventArgs) =>
|
||||
{
|
||||
if(eventArgs.Content is null)
|
||||
if (eventArgs.Content is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -76,11 +78,11 @@ public class NavigationViewContentPresenter : Frame
|
||||
self.OnNavigating(eventArgs);
|
||||
};
|
||||
|
||||
Navigated += static(sender, eventArgs) =>
|
||||
Navigated += static (sender, eventArgs) =>
|
||||
{
|
||||
var self = (NavigationViewContentPresenter)sender;
|
||||
|
||||
if(eventArgs.Content is null)
|
||||
if (eventArgs.Content is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -91,12 +93,12 @@ public class NavigationViewContentPresenter : Frame
|
||||
|
||||
private void ApplyTransitionEffectToNavigatedPage(object content)
|
||||
{
|
||||
if(TransitionDuration < 1)
|
||||
if (TransitionDuration < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_ = TransitionAnimationProvider.ApplyTransition(content, Transition, TransitionDuration);
|
||||
TransitionAnimationProvider.ApplyTransition(content, Transition, TransitionDuration);
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage(
|
||||
@@ -107,16 +109,16 @@ public class NavigationViewContentPresenter : Frame
|
||||
{
|
||||
// The order in which the OnNavigatedToAsync/OnNavigatedFromAsync methods of View and ViewModel are called
|
||||
// is not guaranteed
|
||||
if(content is INavigationAware navigationAwareContent)
|
||||
if (content is INavigationAware navigationAwareContent)
|
||||
{
|
||||
function(navigationAwareContent);
|
||||
}
|
||||
|
||||
if(content is INavigableView<object> { ViewModel: INavigationAware navigationAwareViewModel })
|
||||
if (content is INavigableView<object> { ViewModel: INavigationAware navigationAwareViewModel })
|
||||
{
|
||||
function(navigationAwareViewModel);
|
||||
}
|
||||
else if(content is FrameworkElement { DataContext: INavigationAware viewModel } &&
|
||||
else if (content is FrameworkElement { DataContext: INavigationAware viewModel } &&
|
||||
!ReferenceEquals(viewModel, content))
|
||||
{
|
||||
function(viewModel);
|
||||
@@ -134,9 +136,9 @@ public class NavigationViewContentPresenter : Frame
|
||||
base.OnInitialized(e);
|
||||
|
||||
// REVIEW: I didn't understand something, but why is it necessary?
|
||||
Unloaded += static(sender, _) =>
|
||||
Unloaded += static (sender, _) =>
|
||||
{
|
||||
if(sender is NavigationViewContentPresenter navigator)
|
||||
if (sender is NavigationViewContentPresenter navigator)
|
||||
{
|
||||
NotifyContentAboutNavigatingFrom(navigator.Content);
|
||||
}
|
||||
@@ -145,7 +147,7 @@ public class NavigationViewContentPresenter : Frame
|
||||
|
||||
protected override void OnMouseDown(MouseButtonEventArgs e)
|
||||
{
|
||||
if(e.ChangedButton is MouseButton.XButton1 or MouseButton.XButton2)
|
||||
if (e.ChangedButton is MouseButton.XButton1 or MouseButton.XButton2)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
@@ -158,7 +160,7 @@ public class NavigationViewContentPresenter : Frame
|
||||
{
|
||||
ApplyTransitionEffectToNavigatedPage(eventArgs.Content);
|
||||
|
||||
if(eventArgs.Content is not DependencyObject dependencyObject)
|
||||
if (eventArgs.Content is not DependencyObject dependencyObject)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -170,7 +172,7 @@ public class NavigationViewContentPresenter : Frame
|
||||
{
|
||||
NotifyContentAboutNavigatingTo(eventArgs.Content);
|
||||
|
||||
if(eventArgs.Navigator is not NavigationViewContentPresenter navigator)
|
||||
if (eventArgs.Navigator is not NavigationViewContentPresenter navigator)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -180,7 +182,7 @@ public class NavigationViewContentPresenter : Frame
|
||||
|
||||
protected override void OnPreviewKeyDown(KeyEventArgs e)
|
||||
{
|
||||
if(e.Key == Key.F5)
|
||||
if (e.Key == Key.F5)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user