优化更新代码,添加界面功能并整合
This commit is contained in:
172
WPFluent/Controls/NavigationView/NavigationView.Events.cs
Normal file
172
WPFluent/Controls/NavigationView/NavigationView.Events.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
|
||||
|
||||
|
||||
// Based on Windows UI Library
|
||||
// Copyright(c) Microsoft Corporation.All rights reserved.
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
namespace WPFluent.Controls;
|
||||
|
||||
/// <content>
|
||||
/// Defines events for <see cref="NavigationView"/>.
|
||||
/// </content>
|
||||
public partial class NavigationView
|
||||
{
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="BackRequested"/> routed event.
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent BackRequestedEvent = EventManager.RegisterRoutedEvent(
|
||||
nameof(BackRequested),
|
||||
RoutingStrategy.Bubble,
|
||||
typeof(TypedEventHandler<NavigationView, RoutedEventArgs>),
|
||||
typeof(NavigationView));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="ItemInvoked"/> routed event.
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent ItemInvokedEvent = EventManager.RegisterRoutedEvent(
|
||||
nameof(ItemInvoked),
|
||||
RoutingStrategy.Bubble,
|
||||
typeof(TypedEventHandler<NavigationView, RoutedEventArgs>),
|
||||
typeof(NavigationView));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="Navigated"/> routed event.
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent NavigatedEvent = EventManager.RegisterRoutedEvent(
|
||||
nameof(Navigated),
|
||||
RoutingStrategy.Bubble,
|
||||
typeof(TypedEventHandler<NavigationView, NavigatedEventArgs>),
|
||||
typeof(NavigationView));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="Navigating"/> routed event.
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent NavigatingEvent = EventManager.RegisterRoutedEvent(
|
||||
nameof(Navigating),
|
||||
RoutingStrategy.Bubble,
|
||||
typeof(TypedEventHandler<NavigationView, NavigatingCancelEventArgs>),
|
||||
typeof(NavigationView));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="PaneClosed"/> routed event.
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent PaneClosedEvent = EventManager.RegisterRoutedEvent(
|
||||
nameof(PaneClosed),
|
||||
RoutingStrategy.Bubble,
|
||||
typeof(TypedEventHandler<NavigationView, RoutedEventArgs>),
|
||||
typeof(NavigationView));
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="PaneOpened"/> routed event.
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent PaneOpenedEvent = EventManager.RegisterRoutedEvent(
|
||||
nameof(PaneOpened),
|
||||
RoutingStrategy.Bubble,
|
||||
typeof(TypedEventHandler<NavigationView, RoutedEventArgs>),
|
||||
typeof(NavigationView));
|
||||
|
||||
/// <summary>
|
||||
/// Identifies the <see cref="SelectionChanged"/> routed event.
|
||||
/// </summary>
|
||||
public static readonly RoutedEvent SelectionChangedEvent = EventManager.RegisterRoutedEvent(
|
||||
nameof(SelectionChanged),
|
||||
RoutingStrategy.Bubble,
|
||||
typeof(TypedEventHandler<NavigationView, RoutedEventArgs>),
|
||||
typeof(NavigationView));
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event TypedEventHandler<NavigationView, RoutedEventArgs> BackRequested
|
||||
{
|
||||
add => AddHandler(BackRequestedEvent, value);
|
||||
remove => RemoveHandler(BackRequestedEvent, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event TypedEventHandler<NavigationView, RoutedEventArgs> ItemInvoked
|
||||
{
|
||||
add => AddHandler(ItemInvokedEvent, value);
|
||||
remove => RemoveHandler(ItemInvokedEvent, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event TypedEventHandler<NavigationView, NavigatedEventArgs> Navigated
|
||||
{
|
||||
add => AddHandler(NavigatedEvent, value);
|
||||
remove => RemoveHandler(NavigatedEvent, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event TypedEventHandler<NavigationView, NavigatingCancelEventArgs> Navigating
|
||||
{
|
||||
add => AddHandler(NavigatingEvent, value);
|
||||
remove => RemoveHandler(NavigatingEvent, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event TypedEventHandler<NavigationView, RoutedEventArgs> PaneClosed
|
||||
{
|
||||
add => AddHandler(PaneClosedEvent, value);
|
||||
remove => RemoveHandler(PaneClosedEvent, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event TypedEventHandler<NavigationView, RoutedEventArgs> PaneOpened
|
||||
{
|
||||
add => AddHandler(PaneOpenedEvent, value);
|
||||
remove => RemoveHandler(PaneOpenedEvent, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event TypedEventHandler<NavigationView, RoutedEventArgs> SelectionChanged
|
||||
{
|
||||
add => AddHandler(SelectionChangedEvent, value);
|
||||
remove => RemoveHandler(SelectionChangedEvent, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the back requested event.
|
||||
/// </summary>
|
||||
protected virtual void OnBackRequested() { RaiseEvent(new RoutedEventArgs(BackRequestedEvent)); }
|
||||
|
||||
/// <summary>
|
||||
/// Raises the item invoked event.
|
||||
/// </summary>
|
||||
protected virtual void OnItemInvoked() { RaiseEvent(new RoutedEventArgs(ItemInvokedEvent, this)); }
|
||||
|
||||
/// <summary>
|
||||
/// Raises the navigated requested event.
|
||||
/// </summary>
|
||||
protected virtual void OnNavigated(object page)
|
||||
{
|
||||
var eventArgs = new NavigatedEventArgs(NavigatedEvent, this) { Page = page };
|
||||
|
||||
RaiseEvent(eventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the navigating requested event.
|
||||
/// </summary>
|
||||
protected virtual bool OnNavigating(object sourcePage)
|
||||
{
|
||||
var eventArgs = new NavigatingCancelEventArgs(NavigatingEvent, this) { Page = sourcePage };
|
||||
|
||||
RaiseEvent(eventArgs);
|
||||
|
||||
return eventArgs.Cancel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the pane closed event.
|
||||
/// </summary>
|
||||
protected virtual void OnPaneClosed() { RaiseEvent(new RoutedEventArgs(PaneClosedEvent, this)); }
|
||||
|
||||
/// <summary>
|
||||
/// Raises the pane opened event.
|
||||
/// </summary>
|
||||
protected virtual void OnPaneOpened() { RaiseEvent(new RoutedEventArgs(PaneOpenedEvent, this)); }
|
||||
|
||||
/// <summary>
|
||||
/// Raises the selection changed event.
|
||||
/// </summary>
|
||||
protected virtual void OnSelectionChanged() { RaiseEvent(new RoutedEventArgs(SelectionChangedEvent, this)); }
|
||||
}
|
||||
Reference in New Issue
Block a user