Skip to content

Commit 1f7d076

Browse files
committed
invalidate command manager to reset button states on dialogs. issue #445
1 parent 51c3840 commit 1f7d076

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

MaterialDesignThemes.Wpf/DialogHost.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
265265
// Don't attempt to Invoke if _restoreFocusDialogClose hasn't been assigned yet. Can occur
266266
// if the MainWindow has started up minimized. Even when Show() has been called, this doesn't
267267
// seem to have been set.
268-
dialogHost.Dispatcher.InvokeAsync(() => dialogHost._restoreFocusDialogClose?.Focus(), DispatcherPriority.Input);
268+
dialogHost.Dispatcher.InvokeAsync(() => dialogHost._restoreFocusDialogClose?.Focus(), DispatcherPriority.Input);
269269

270270
return;
271271
}
@@ -289,6 +289,7 @@ private static void IsOpenPropertyChangedCallback(DependencyObject dependencyObj
289289
dialogHost.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
290290
{
291291
var child = dialogHost.FocusPopup();
292+
CommandManager.InvalidateRequerySuggested();
292293

293294
//https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/issues/187
294295
//totally not happy about this, but on immediate validation we can get some weird looking stuff...give WPF a kick to refresh...

MaterialDesignThemes.Wpf/DialogSession.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Windows.Input;
23
using System.Windows.Threading;
34

45
namespace MaterialDesignThemes.Wpf
@@ -40,7 +41,11 @@ public void UpdateContent(object content)
4041

4142
_owner.AssertTargetableContent();
4243
_owner.DialogContent = content;
43-
_owner.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => _owner.FocusPopup()));
44+
_owner.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
45+
{
46+
_owner.FocusPopup();
47+
CommandManager.InvalidateRequerySuggested();
48+
}));
4449
}
4550

4651
/// <summary>

0 commit comments

Comments
 (0)