@@ -235,6 +235,7 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
235235 dialogHost . _attachedDialogClosingEventHandler = null ;
236236 dialogHost . _session . IsEnded = true ;
237237 dialogHost . _session = null ;
238+
238239 return ;
239240 }
240241
@@ -252,10 +253,17 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
252253 dialogHost . DialogOpenedCallback ? . Invoke ( dialogHost , dialogOpenedEventArgs ) ;
253254 dialogHost . _asyncShowOpenedEventHandler ? . Invoke ( dialogHost , dialogOpenedEventArgs ) ;
254255
255- dialogHost . Dispatcher . BeginInvoke ( DispatcherPriority . Loaded , new Action ( ( ) =>
256+ dialogHost . Dispatcher . BeginInvoke ( DispatcherPriority . Background , new Action ( ( ) =>
256257 {
257- dialogHost . _popup ? . Child ? . Focus ( ) ;
258- dialogHost . _popup ? . Child ? . MoveFocus ( new TraversalRequest ( FocusNavigationDirection . Next ) ) ;
258+ var child = dialogHost . _popup ? . Child ;
259+ if ( child == null ) return ;
260+
261+ child . Focus ( ) ;
262+ child . MoveFocus ( new TraversalRequest ( FocusNavigationDirection . Next ) ) ;
263+
264+ //https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/issues/187
265+ //totally not happy about this, but on immediate validation we can get some wierd looking stuff...give WPF a kick to refresh...
266+ Task . Delay ( 300 ) . ContinueWith ( t => child . Dispatcher . BeginInvoke ( new Action ( ( ) => child . InvalidateVisual ( ) ) ) ) ;
259267 } ) ) ;
260268 }
261269
@@ -498,8 +506,8 @@ private void OpenDialogHandler(object sender, ExecutedRoutedEventArgs executedRo
498506
499507 DialogContent = executedRoutedEventArgs . Parameter ;
500508 }
501-
502- ValidationAssist . SetSuppress ( _popupContentControl , false ) ;
509+
510+ SetCurrentValue ( IsOpenProperty , true ) ;
503511
504512 executedRoutedEventArgs . Handled = true ;
505513 }
0 commit comments