@@ -11,12 +11,20 @@ public static class IDialogServiceCompatExtensions
11
11
/// </summary>
12
12
/// <param name="dialogService">The DialogService</param>
13
13
/// <param name="name">The name of the dialog to show.</param>
14
- /// <param name="parameters">The parameters to pass to the dialog.</param>
14
+ public static void Show ( this IDialogService dialogService , string name )
15
+ {
16
+ Show ( dialogService , name , null , null , null ) ;
17
+ }
18
+
19
+ /// <summary>
20
+ /// Shows a non-modal dialog.
21
+ /// </summary>
22
+ /// <param name="dialogService">The DialogService</param>
23
+ /// <param name="name">The name of the dialog to show.</param>
15
24
/// <param name="callback">The action to perform when the dialog is closed.</param>
16
- public static void Show ( this IDialogService dialogService , string name , IDialogParameters parameters , Action < IDialogResult > callback )
25
+ public static void Show ( this IDialogService dialogService , string name , Action < IDialogResult > callback )
17
26
{
18
- parameters = EnsureShowNonModalParameter ( parameters ) ;
19
- dialogService . ShowDialog ( name , parameters , new DialogCallback ( ) . OnClose ( callback ) ) ;
27
+ Show ( dialogService , name , null , callback , null ) ;
20
28
}
21
29
22
30
/// <summary>
@@ -26,48 +34,48 @@ public static void Show(this IDialogService dialogService, string name, IDialogP
26
34
/// <param name="name">The name of the dialog to show.</param>
27
35
/// <param name="parameters">The parameters to pass to the dialog.</param>
28
36
/// <param name="callback">The action to perform when the dialog is closed.</param>
29
- /// <param name="windowName">The name of the hosting window registered with the IContainerRegistry.</param>
30
- public static void Show ( this IDialogService dialogService , string name , IDialogParameters parameters , Action < IDialogResult > callback , string windowName )
37
+ public static void Show ( this IDialogService dialogService , string name , IDialogParameters parameters , Action < IDialogResult > callback )
31
38
{
32
- parameters = EnsureShowNonModalParameter ( parameters ) ;
33
-
34
- if ( ! string . IsNullOrEmpty ( windowName ) )
35
- parameters . Add ( KnownDialogParameters . WindowName , windowName ) ;
36
-
37
- dialogService . ShowDialog ( name , parameters , new DialogCallback ( ) . OnClose ( callback ) ) ;
39
+ Show ( dialogService , name , parameters , callback , null ) ;
38
40
}
39
41
40
42
/// <summary>
41
43
/// Shows a non-modal dialog.
42
44
/// </summary>
43
45
/// <param name="dialogService">The DialogService</param>
44
46
/// <param name="name">The name of the dialog to show.</param>
45
- public static void Show ( this IDialogService dialogService , string name )
47
+ /// <param name="parameters">The parameters to pass to the dialog.</param>
48
+ /// <param name="callback">The action to perform when the dialog is closed.</param>
49
+ /// <param name="windowName">The name of the hosting window registered with the IContainerRegistry.</param>
50
+ public static void Show ( this IDialogService dialogService , string name , IDialogParameters parameters , Action < IDialogResult > callback , string windowName )
46
51
{
47
- var parameters = EnsureShowNonModalParameter ( null ) ;
48
- dialogService . Show ( name , parameters , null ) ;
52
+ ShowDialogInternal ( dialogService , name , parameters , callback , windowName , true ) ;
49
53
}
50
54
51
55
/// <summary>
52
- /// Shows a non- modal dialog.
56
+ /// Shows a modal dialog.
53
57
/// </summary>
54
58
/// <param name="dialogService">The DialogService</param>
55
59
/// <param name="name">The name of the dialog to show.</param>
60
+ /// <param name="parameters">The parameters to pass to the dialog.</param>
56
61
/// <param name="callback">The action to perform when the dialog is closed.</param>
57
- public static void Show ( this IDialogService dialogService , string name , Action < IDialogResult > callback )
62
+ /// <param name="windowName">The name of the hosting window registered with the IContainerRegistry.</param>
63
+ public static void ShowDialog ( this IDialogService dialogService , string name , IDialogParameters parameters , Action < IDialogResult > callback , string windowName )
58
64
{
59
- var parameters = EnsureShowNonModalParameter ( null ) ;
60
- dialogService . Show ( name , parameters , callback ) ;
65
+ ShowDialogInternal ( dialogService , name , parameters , callback , windowName , false ) ;
61
66
}
62
67
63
- private static IDialogParameters EnsureShowNonModalParameter ( IDialogParameters parameters )
68
+ private static void ShowDialogInternal ( IDialogService dialogService , string name , IDialogParameters parameters , Action < IDialogResult > callback , string windowName , bool isNonModal )
64
69
{
65
70
parameters ??= new DialogParameters ( ) ;
66
71
67
- if ( ! parameters . ContainsKey ( KnownDialogParameters . ShowNonModal ) )
72
+ if ( ! string . IsNullOrEmpty ( windowName ) )
73
+ parameters . Add ( KnownDialogParameters . WindowName , windowName ) ;
74
+
75
+ if ( isNonModal )
68
76
parameters . Add ( KnownDialogParameters . ShowNonModal , true ) ;
69
77
70
- return parameters ;
78
+ dialogService . ShowDialog ( name , parameters , new DialogCallback ( ) . OnClose ( callback ) ) ;
71
79
}
72
80
#endif
73
81
}
0 commit comments