File tree Expand file tree Collapse file tree 4 files changed +33
-6
lines changed Expand file tree Collapse file tree 4 files changed +33
-6
lines changed Original file line number Diff line number Diff line change @@ -288,8 +288,8 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
288
288
289
289
dialogHost . Dispatcher . BeginInvoke ( DispatcherPriority . Background , new Action ( ( ) =>
290
290
{
291
- var child = dialogHost . FocusPopup ( ) ;
292
291
CommandManager . InvalidateRequerySuggested ( ) ;
292
+ var child = dialogHost . FocusPopup ( ) ;
293
293
294
294
//https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/issues/187
295
295
//totally not happy about this, but on immediate validation we can get some weird looking stuff...give WPF a kick to refresh...
@@ -575,8 +575,14 @@ internal UIElement FocusPopup()
575
575
var child = _popup ? . Child ;
576
576
if ( child == null ) return null ;
577
577
578
- child . Focus ( ) ;
579
- child . MoveFocus ( new TraversalRequest ( FocusNavigationDirection . Next ) ) ;
578
+ CommandManager . InvalidateRequerySuggested ( ) ;
579
+ var focusable = child . VisualDepthFirstTraversal ( ) . OfType < UIElement > ( ) . FirstOrDefault ( ui => ui . Focusable && ui . IsVisible ) ;
580
+ focusable ? . Dispatcher . InvokeAsync ( ( ) =>
581
+ {
582
+ if ( ! focusable . Focus ( ) ) return ;
583
+ focusable . MoveFocus ( new TraversalRequest ( FocusNavigationDirection . First ) ) ;
584
+ } , DispatcherPriority . Background ) ;
585
+
580
586
return child ;
581
587
}
582
588
Original file line number Diff line number Diff line change @@ -42,9 +42,8 @@ public void UpdateContent(object content)
42
42
_owner . AssertTargetableContent ( ) ;
43
43
_owner . DialogContent = content ;
44
44
_owner . Dispatcher . BeginInvoke ( DispatcherPriority . Background , new Action ( ( ) =>
45
- {
46
- _owner . FocusPopup ( ) ;
47
- CommandManager . InvalidateRequerySuggested ( ) ;
45
+ {
46
+ _owner . FocusPopup ( ) ;
48
47
} ) ) ;
49
48
}
50
49
Original file line number Diff line number Diff line change @@ -24,6 +24,27 @@ public static IEnumerable<DependencyObject> VisualDepthFirstTraversal(this Depen
24
24
}
25
25
}
26
26
27
+ public static IEnumerable < DependencyObject > VisualBreadthFirstTraversal ( this DependencyObject node )
28
+ {
29
+ if ( node == null ) throw new ArgumentNullException ( nameof ( node ) ) ;
30
+
31
+ for ( var i = 0 ; i < VisualTreeHelper . GetChildrenCount ( node ) ; i ++ )
32
+ {
33
+ var child = VisualTreeHelper . GetChild ( node , i ) ;
34
+ yield return child ;
35
+ }
36
+
37
+ for ( var i = 0 ; i < VisualTreeHelper . GetChildrenCount ( node ) ; i ++ )
38
+ {
39
+ var child = VisualTreeHelper . GetChild ( node , i ) ;
40
+
41
+ foreach ( var descendant in child . VisualDepthFirstTraversal ( ) )
42
+ {
43
+ yield return descendant ;
44
+ }
45
+ }
46
+ }
47
+
27
48
public static bool IsAncestorOf ( this DependencyObject parent , DependencyObject node )
28
49
{
29
50
return node != null && parent . VisualDepthFirstTraversal ( ) . Contains ( node ) ;
Original file line number Diff line number Diff line change 617
617
TextElement.FontSize=" 13"
618
618
TextOptions.TextFormattingMode=" Ideal"
619
619
TextOptions.TextRenderingMode=" Auto"
620
+ FocusManager.IsFocusScope=" True"
620
621
Foreground =" {DynamicResource MaterialDesignBody}"
621
622
FontFamily =" {StaticResource MaterialDesignFont}"
622
623
Focusable =" False"
You can’t perform that action at this time.
0 commit comments