Skip to content

Commit 4d2fb1f

Browse files
committed
ensure open dialog event is called. fix #123
1 parent 1e1cc19 commit 4d2fb1f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

MainDemo.Wpf/Domain/DialogsViewModel.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,17 @@ private async void ExecuteRunExtendedDialog(object o)
5757
};
5858

5959
//show the dialog
60-
var result = await DialogHost.Show(view, "RootDialog", ExtendedClosingEventHandler);
60+
var result = await DialogHost.Show(view, "RootDialog", ExtendedOpenedEventHandler, ExtendedClosingEventHandler);
6161

6262
//check the result...
6363
Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL"));
6464
}
6565

66+
private void ExtendedOpenedEventHandler(object sender, DialogOpenedEventArgs eventargs)
67+
{
68+
Console.WriteLine("You could intercept the open and affect the dialog using eventArgs.Session.");
69+
}
70+
6671
private void ExtendedClosingEventHandler(object sender, DialogClosingEventArgs eventArgs)
6772
{
6873
if ((bool)eventArgs.Parameter == false) return;

MaterialDesignThemes.Wpf/DialogHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ public static async Task<object> Show(object content, object dialogIndetifier, D
156156

157157
targets[0].AssertTargetableContent();
158158
targets[0].DialogContent = content;
159-
targets[0].SetCurrentValue(IsOpenProperty, true);
160159
targets[0]._asyncShowOpenedEventHandler = openedEventHandler;
161160
targets[0]._asyncShowClosingEventHandler = closingEventHandler;
161+
targets[0].SetCurrentValue(IsOpenProperty, true);
162162

163163
var task = new Task(() =>
164164
{

0 commit comments

Comments
 (0)