@@ -141,6 +141,30 @@ public DataTemplate ToggleCheckedContentTemplate
141
141
set { SetValue ( ToggleCheckedContentTemplateProperty , value ) ; }
142
142
}
143
143
144
+ public static readonly DependencyProperty ToggleCheckedContentCommandProperty = DependencyProperty . Register (
145
+ "ToggleCheckedContentCommand" , typeof ( ICommand ) , typeof ( PopupBox ) , new PropertyMetadata ( default ( ICommand ) ) ) ;
146
+
147
+ /// <summary>
148
+ /// Command to execute if toggle is checked (popup is open) and <see cref="ToggleCheckedContent"/> is set.
149
+ /// </summary>
150
+ public ICommand ToggleCheckedContentCommand
151
+ {
152
+ get { return ( ICommand ) GetValue ( ToggleCheckedContentCommandProperty ) ; }
153
+ set { SetValue ( ToggleCheckedContentCommandProperty , value ) ; }
154
+ }
155
+
156
+ public static readonly DependencyProperty ToggleCheckedContentCommandParameterProperty = DependencyProperty . Register (
157
+ "ToggleCheckedContentCommandParameter" , typeof ( object ) , typeof ( PopupBox ) , new PropertyMetadata ( default ( object ) ) ) ;
158
+
159
+ /// <summary>
160
+ /// Command parameter to use in conjunction with <see cref="ToggleCheckedContentCommand"/>.
161
+ /// </summary>
162
+ public object ToggleCheckedContentCommandParameter
163
+ {
164
+ get { return ( object ) GetValue ( ToggleCheckedContentCommandParameterProperty ) ; }
165
+ set { SetValue ( ToggleCheckedContentCommandParameterProperty , value ) ; }
166
+ }
167
+
144
168
public static readonly DependencyProperty PopupContentProperty = DependencyProperty . Register (
145
169
"PopupContent" , typeof ( object ) , typeof ( PopupBox ) , new PropertyMetadata ( default ( object ) ) ) ;
146
170
@@ -470,6 +494,14 @@ private void ToggleButtonOnPreviewMouseLeftButtonUp(object sender, MouseButtonEv
470
494
{
471
495
if ( PopupMode == PopupBoxPopupMode . Click || ! IsPopupOpen ) return ;
472
496
497
+ if ( ToggleCheckedContent != null
498
+ && ToggleCheckedContentCommand != null
499
+ && ToggleCheckedContentCommand . CanExecute ( ToggleCheckedContentCommandParameter )
500
+ )
501
+ {
502
+ ToggleCheckedContentCommand . Execute ( ToggleCheckedContentCommandParameter ) ;
503
+ }
504
+
473
505
Close ( ) ;
474
506
Mouse . Capture ( null ) ;
475
507
mouseButtonEventArgs . Handled = true ;
0 commit comments