mirror of
https://github.com/PrismLibrary/Prism.git
synced 2026-10-29 13:38:03 +08:00
Modify e2e test for GoBack Method
This commit is contained in:
@@ -29,6 +29,7 @@ public abstract class ViewModelBase : BindableBase, IInitialize, INavigatedAware
|
||||
SelectedDialog = AvailableDialogs.FirstOrDefault();
|
||||
ShowDialog = new DelegateCommand(OnShowDialogCommand, () => !string.IsNullOrEmpty(SelectedDialog))
|
||||
.ObservesProperty(() => SelectedDialog);
|
||||
GoBack = new DelegateCommand<string>(OnGoBack);
|
||||
}
|
||||
|
||||
public IEnumerable<string> AvailableDialogs { get; }
|
||||
@@ -52,6 +53,8 @@ public abstract class ViewModelBase : BindableBase, IInitialize, INavigatedAware
|
||||
|
||||
public DelegateCommand ShowDialog { get; }
|
||||
|
||||
public DelegateCommand<string> GoBack { get; }
|
||||
|
||||
private void OnNavigateCommandExecuted(string uri)
|
||||
{
|
||||
Messages.Add($"OnNavigateCommandExecuted: {uri}");
|
||||
@@ -74,6 +77,12 @@ public abstract class ViewModelBase : BindableBase, IInitialize, INavigatedAware
|
||||
private void DialogCallback(IDialogResult result) =>
|
||||
Messages.Add("Dialog Closed");
|
||||
|
||||
private void OnGoBack(string viewName)
|
||||
{
|
||||
Messages.Add($"On Go Back {viewName}");
|
||||
_navigationService.GoBackAsync(viewName);
|
||||
}
|
||||
|
||||
public void Initialize(INavigationParameters parameters)
|
||||
{
|
||||
Messages.Add("ViewModel Initialized");
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
x:DataType="loc:ViewModelBase"
|
||||
Title="{Binding Title}"
|
||||
BackgroundColor="White">
|
||||
<Grid RowDefinitions="*,Auto,Auto,Auto"
|
||||
<Grid RowDefinitions="*,Auto,Auto,Auto,Auto"
|
||||
ColumnDefinitions="*,*">
|
||||
<CollectionView ItemsSource="{Binding Messages}"
|
||||
Grid.ColumnSpan="2">
|
||||
@@ -57,5 +57,11 @@
|
||||
Margin="10"
|
||||
Grid.Row="3"
|
||||
Grid.Column="1"/>
|
||||
<Button Text="Go Back View B"
|
||||
Command="{Binding GoBack}"
|
||||
CommandParameter="ViewB"
|
||||
Margin="10"
|
||||
Grid.Row="4"
|
||||
Grid.Column="0"/>
|
||||
</Grid>
|
||||
</ContentPage>
|
||||
</ContentPage>
|
||||
|
||||
Reference in New Issue
Block a user