Skip to content

Commit c54ceca

Browse files
committed
chore: adding DialogSample for Uno App
1 parent a45c90d commit c54ceca

File tree

5 files changed

+25
-51
lines changed

5 files changed

+25
-51
lines changed

e2e/Uno/ModuleA/Dialogs/AlertDialog.xaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
d:DesignWidth="400">
1111

1212
<StackPanel>
13-
<TextBlock Text="{Binding Title}"
14-
FontSize="20"
15-
FontWeight="Bold" />
1613
<TextBlock Text="{Binding Message}" />
1714
<Button Content="OK"
18-
Command="{Binding CloseCommand}" />
15+
Command="{Binding CloseCommand}"
16+
Margin="0,15"/>
1917
</StackPanel>
2018
</UserControl>

e2e/Uno/ModuleA/ModuleAModule.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using ModuleA.Dialogs;
12
using ModuleA.Views;
3+
using AlertDialog = ModuleA.Dialogs.AlertDialog;
24

35
namespace ModuleA;
46

@@ -15,6 +17,7 @@ public void RegisterTypes(IContainerRegistry containerRegistry)
1517
{
1618
containerRegistry.RegisterForNavigation<ViewA>();
1719
containerRegistry.RegisterForNavigation<ViewB>();
20+
containerRegistry.RegisterDialog<AlertDialog, AlertDialogViewModel>();
1821
}
1922

2023
public void OnInitialized(IContainerProvider containerProvider)
Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Collections.ObjectModel;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
1+
using System.Windows.Input;
72

83
namespace ModuleA.ViewModels;
94

105
internal class ViewAViewModel : ViewModelBase
116
{
12-
public ViewAViewModel(IRegionManager regionManager)
7+
private readonly IDialogService _dialogService;
8+
9+
public ViewAViewModel(IRegionManager regionManager, IDialogService dialogService)
1310
: base(regionManager)
1411
{
12+
_dialogService = dialogService;
13+
ShowAlertCommand = new DelegateCommand(ShowDialog);
14+
}
15+
16+
public ICommand ShowAlertCommand { get; }
17+
18+
private void ShowDialog()
19+
{
20+
_dialogService.ShowDialog("AlertDialog", new DialogParameters
21+
{
22+
{ "title", "Oh Snap" },
23+
{ "message", "You can actually create much more amazing dialogs with Prism. Hello from ViewA!" }
24+
});
1525
}
1626
}

e2e/Uno/ModuleA/Views/ViewA.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
d:DesignHeight="300"
1010
d:DesignWidth="400">
1111

12-
<Grid>
12+
<StackPanel>
1313
<TextBlock Text="View A" FontSize="72" />
14-
</Grid>
14+
<Button Content="Show Dialog" Command="{Binding ShowAlertCommand}" />
15+
</StackPanel>
1516
</UserControl>

src/Wpf/Prism.Wpf/Dialogs/IDialogServiceCompatExtensions.cs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -72,43 +72,5 @@ private static IDialogParameters EnsureShowNonModalParameter(IDialogParameters p
7272
return parameters;
7373
}
7474
#endif
75-
/// <summary>
76-
/// Shows a modal dialog.
77-
/// </summary>
78-
/// <param name="dialogService">The DialogService</param>
79-
/// <param name="name">The name of the dialog to show.</param>
80-
public static void ShowDialog(this IDialogService dialogService, string name)
81-
{
82-
dialogService.ShowDialog(name, new DialogParameters(), DialogCallback.Empty);
83-
}
84-
85-
/// <summary>
86-
/// Shows a modal dialog.
87-
/// </summary>
88-
/// <param name="dialogService">The DialogService</param>
89-
/// <param name="name">The name of the dialog to show.</param>
90-
/// <param name="callback">The action to perform when the dialog is closed.</param>
91-
public static void ShowDialog(this IDialogService dialogService, string name, Action<IDialogResult> callback)
92-
{
93-
dialogService.ShowDialog(name, new DialogParameters(), new DialogCallback().OnClose(callback));
94-
}
95-
96-
/// <summary>
97-
/// Shows a modal dialog.
98-
/// </summary>
99-
/// <param name="dialogService">The DialogService</param>
100-
/// <param name="name">The name of the dialog to show.</param>
101-
/// <param name="parameters">The parameters to pass to the dialog.</param>
102-
/// <param name="callback">The action to perform when the dialog is closed.</param>
103-
/// <param name="windowName">The name of the hosting window registered with the IContainerRegistry.</param>
104-
public static void ShowDialog(this IDialogService dialogService, string name, IDialogParameters parameters, Action<IDialogResult> callback, string windowName)
105-
{
106-
parameters ??= new DialogParameters();
107-
108-
if (!string.IsNullOrEmpty(windowName))
109-
parameters.Add(KnownDialogParameters.WindowName, windowName);
110-
111-
dialogService.ShowDialog(name, parameters, new DialogCallback().OnClose(callback));
112-
}
11375
}
11476
}

0 commit comments

Comments
 (0)