File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -266,17 +266,13 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
266
266
267
267
dialogHost . Dispatcher . BeginInvoke ( DispatcherPriority . Background , new Action ( ( ) =>
268
268
{
269
- var child = dialogHost . _popup ? . Child ;
270
- if ( child == null ) return ;
271
-
272
- child . Focus ( ) ;
273
- child . MoveFocus ( new TraversalRequest ( FocusNavigationDirection . Next ) ) ;
269
+ var child = dialogHost . FocusPopup ( ) ;
274
270
275
271
//https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/issues/187
276
272
//totally not happy about this, but on immediate validation we can get some weird looking stuff...give WPF a kick to refresh...
277
- Task . Delay ( 300 ) . ContinueWith ( t => child . Dispatcher . BeginInvoke ( new Action ( ( ) => child . InvalidateVisual ( ) ) ) ) ;
273
+ Task . Delay ( 300 ) . ContinueWith ( t => child . Dispatcher . BeginInvoke ( new Action ( ( ) => child . InvalidateVisual ( ) ) ) ) ;
278
274
} ) ) ;
279
- }
275
+ }
280
276
281
277
public bool IsOpen
282
278
{
@@ -512,6 +508,20 @@ internal void Close(object parameter)
512
508
_closeDialogExecutionParameter = parameter ;
513
509
}
514
510
511
+ /// <summary>
512
+ /// Attempts to focus the content of a popup.
513
+ /// </summary>
514
+ /// <returns>The popup content.</returns>
515
+ internal UIElement FocusPopup ( )
516
+ {
517
+ var child = _popup ? . Child ;
518
+ if ( child == null ) return null ;
519
+
520
+ child . Focus ( ) ;
521
+ child . MoveFocus ( new TraversalRequest ( FocusNavigationDirection . Next ) ) ;
522
+ return child ;
523
+ }
524
+
515
525
protected override void OnPreviewMouseDown ( MouseButtonEventArgs e )
516
526
{
517
527
var window = Window . GetWindow ( this ) ;
Original file line number Diff line number Diff line change 1
1
using System ;
2
+ using System . Windows . Threading ;
2
3
3
4
namespace MaterialDesignThemes . Wpf
4
5
{
@@ -39,6 +40,7 @@ public void UpdateContent(object content)
39
40
40
41
_owner . AssertTargetableContent ( ) ;
41
42
_owner . DialogContent = content ;
43
+ _owner . Dispatcher . BeginInvoke ( DispatcherPriority . Background , new Action ( ( ) => _owner . FocusPopup ( ) ) ) ;
42
44
}
43
45
44
46
/// <summary>
You can’t perform that action at this time.
0 commit comments