|
1 | 1 | using System;
|
| 2 | +using System.ComponentModel; |
2 | 3 | using System.Diagnostics;
|
3 | 4 | using System.Linq;
|
4 | 5 | using System.Runtime.InteropServices;
|
@@ -272,6 +273,27 @@ public PopupBoxPopupMode PopupMode
|
272 | 273 | /// </summary>
|
273 | 274 | public CustomPopupPlacementCallback PopupPlacementMethod => GetPopupPlacement;
|
274 | 275 |
|
| 276 | + /// <summary> |
| 277 | + /// Event raised when the checked toggled content (if set) is clicked. |
| 278 | + /// </summary> |
| 279 | + public static readonly RoutedEvent ToggleCheckedContentClickEvent = EventManager.RegisterRoutedEvent("ToggleCheckedContentClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PopupBox)); |
| 280 | + |
| 281 | + /// <summary> |
| 282 | + /// Event raised when the checked toggled content (if set) is clicked. |
| 283 | + /// </summary> |
| 284 | + [Category("Behavior")] |
| 285 | + public event RoutedEventHandler ToggleCheckedContentClick { add { AddHandler(ToggleCheckedContentClickEvent, value); } remove { RemoveHandler(ToggleCheckedContentClickEvent, value); } } |
| 286 | + |
| 287 | + |
| 288 | + /// <summary> |
| 289 | + /// Raises <see cref="ToggleCheckedContentClickEvent"/>. |
| 290 | + /// </summary> |
| 291 | + protected virtual void OnToggleCheckedContentClick() |
| 292 | + { |
| 293 | + var newEvent = new RoutedEventArgs(ToggleCheckedContentClickEvent, this); |
| 294 | + RaiseEvent(newEvent); |
| 295 | + } |
| 296 | + |
275 | 297 | public override void OnApplyTemplate()
|
276 | 298 | {
|
277 | 299 | if (_popup != null)
|
@@ -495,12 +517,16 @@ private void ToggleButtonOnPreviewMouseLeftButtonUp(object sender, MouseButtonEv
|
495 | 517 | {
|
496 | 518 | if (PopupMode == PopupBoxPopupMode.Click || !IsPopupOpen) return;
|
497 | 519 |
|
498 |
| - if (ToggleCheckedContent != null |
499 |
| - && ToggleCheckedContentCommand != null |
500 |
| - && ToggleCheckedContentCommand.CanExecute(ToggleCheckedContentCommandParameter) |
501 |
| - ) |
| 520 | + if (ToggleCheckedContent != null) |
502 | 521 | {
|
503 |
| - ToggleCheckedContentCommand.Execute(ToggleCheckedContentCommandParameter); |
| 522 | + OnToggleCheckedContentClick(); |
| 523 | + |
| 524 | + if (ToggleCheckedContentCommand != null |
| 525 | + && ToggleCheckedContentCommand.CanExecute(ToggleCheckedContentCommandParameter) |
| 526 | + ) |
| 527 | + { |
| 528 | + ToggleCheckedContentCommand.Execute(ToggleCheckedContentCommandParameter); |
| 529 | + } |
504 | 530 | }
|
505 | 531 |
|
506 | 532 | Close();
|
|
0 commit comments