-
-
Notifications
You must be signed in to change notification settings - Fork 966
Expand file tree
/
Copy pathNavigationView.Events.cs
More file actions
185 lines (159 loc) · 6.08 KB
/
NavigationView.Events.cs
File metadata and controls
185 lines (159 loc) · 6.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
// Copyright (C) Leszek Pomianowski and WPF UI Contributors.
// All Rights Reserved.
// Based on Windows UI Library
// Copyright(c) Microsoft Corporation.All rights reserved.
// ReSharper disable once CheckNamespace
namespace Wpf.Ui.Controls;
/// <content>
/// Defines events for <see cref="NavigationView"/>.
/// </content>
public partial class 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="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="SelectionChanged"/> routed event.</summary>
public static readonly RoutedEvent SelectionChangedEvent = EventManager.RegisterRoutedEvent(
nameof(SelectionChanged),
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="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="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="Navigated"/> routed event.</summary>
public static readonly RoutedEvent NavigatedEvent = EventManager.RegisterRoutedEvent(
nameof(Navigated),
RoutingStrategy.Bubble,
typeof(TypedEventHandler<NavigationView, NavigatedEventArgs>),
typeof(NavigationView)
);
/// <inheritdoc/>
public event TypedEventHandler<NavigationView, RoutedEventArgs> PaneOpened
{
add => AddHandler(PaneOpenedEvent, value);
remove => RemoveHandler(PaneOpenedEvent, value);
}
/// <inheritdoc/>
public event TypedEventHandler<NavigationView, RoutedEventArgs> PaneClosed
{
add => AddHandler(PaneClosedEvent, value);
remove => RemoveHandler(PaneClosedEvent, value);
}
/// <inheritdoc/>
public event TypedEventHandler<NavigationView, RoutedEventArgs> SelectionChanged
{
add => AddHandler(SelectionChangedEvent, value);
remove => RemoveHandler(SelectionChangedEvent, value);
}
/// <inheritdoc/>
public event TypedEventHandler<NavigationView, RoutedEventArgs> ItemInvoked
{
add => AddHandler(ItemInvokedEvent, value);
remove => RemoveHandler(ItemInvokedEvent, value);
}
/// <inheritdoc/>
public event TypedEventHandler<NavigationView, RoutedEventArgs> BackRequested
{
add => AddHandler(BackRequestedEvent, value);
remove => RemoveHandler(BackRequestedEvent, value);
}
/// <inheritdoc/>
public event TypedEventHandler<NavigationView, NavigatingCancelEventArgs> Navigating
{
add => AddHandler(NavigatingEvent, value);
remove => RemoveHandler(NavigatingEvent, value);
}
/// <inheritdoc/>
public event TypedEventHandler<NavigationView, NavigatedEventArgs> Navigated
{
add => AddHandler(NavigatedEvent, value);
remove => RemoveHandler(NavigatedEvent, value);
}
/// <summary>
/// Raises the pane opened event.
/// </summary>
protected virtual void OnPaneOpened()
{
RaiseEvent(new RoutedEventArgs(PaneOpenedEvent, this));
UpdatePaneColumnWidthForToggle();
}
/// <summary>
/// Raises the pane closed event.
/// </summary>
protected virtual void OnPaneClosed()
{
RaiseEvent(new RoutedEventArgs(PaneClosedEvent, this));
UpdatePaneColumnWidthForToggle();
}
/// <summary>
/// Raises the selection changed event.
/// </summary>
protected virtual void OnSelectionChanged()
{
RaiseEvent(new RoutedEventArgs(SelectionChangedEvent, this));
}
/// <summary>
/// Raises the item invoked event.
/// </summary>
protected virtual void OnItemInvoked()
{
RaiseEvent(new RoutedEventArgs(ItemInvokedEvent, this));
}
/// <summary>
/// Raises the back requested event.
/// </summary>
protected virtual void OnBackRequested()
{
RaiseEvent(new RoutedEventArgs(BackRequestedEvent));
}
/// <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 navigated requested event.
/// </summary>
protected virtual void OnNavigated(object page)
{
var eventArgs = new NavigatedEventArgs(NavigatedEvent, this) { Page = page };
RaiseEvent(eventArgs);
}
}