Skip to content

Commit

Permalink
Adding fifth page
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrandolph committed Oct 14, 2020
1 parent d2e7ef1 commit e7cad72
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 4 deletions.
10 changes: 10 additions & 0 deletions MvvmNavigation.Core/Messages/PleadTheFifthMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using BuildIt.Navigation.Messages;

namespace MvvmNavigation.Messages
{
public class PleadTheFifthMessage : CompletedMessage
{
public PleadTheFifthMessage() : base() { }
public PleadTheFifthMessage(object sender) : base(sender) { }
}
}
5 changes: 1 addition & 4 deletions MvvmNavigation.Core/MvvmApplicationServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ protected override void InitializeApplicationServices(IServiceCollection service
serviceRegistrations.AddSingleton<INavigationMessageRoutes>(sp =>
{
var routes = new NavigationMessageRoutes()
.RegisterNavigate<MainViewModel, PleadTheFifthMessage, FifthViewModel>()
.RegisterNavigate<MainViewModel, CompletedMessage, SecondViewModel>()
.Register<MainViewModel, CompletedWithStatusMessage<CompletionStates>>((vm, msg, nav) =>
{
Expand All @@ -56,10 +57,6 @@ protected override void InitializeApplicationServices(IServiceCollection service
return routes;
});

//serviceRegistrations.AddTransient<MainViewModel>();
//serviceRegistrations.AddTransient<SecondViewModel>();
//serviceRegistrations.AddTransient<ThirdViewModel>();
//serviceRegistrations.AddTransient<FourthViewModel>();

RegisterServices(serviceRegistrations);
}
Expand Down
20 changes: 20 additions & 0 deletions MvvmNavigation.Core/ViewModels/FifthViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using BuildIt.Navigation;
using BuildIt.Navigation.Messages;
using System;

namespace MvvmNavigation.ViewModels
{
[Register]
public class FifthViewModel
{
[EventMessage(typeof(CloseMessage))]
public event EventHandler FifthDone;

public string Title => "Page 5";

public void RaiseFifthDone()
{
FifthDone?.Invoke(this, EventArgs.Empty);
}
}
}
15 changes: 15 additions & 0 deletions MvvmNavigation/MvvmNavigation.Shared/FifthPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Page x:Class="MvvmNavigation.FifthPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center">
<TextBlock Text="{x:Bind ViewModel.Title}" />
<Button Content="Go Back"
Click="{x:Bind ViewModel.RaiseFifthDone}" />
</StackPanel>
</Page>
17 changes: 17 additions & 0 deletions MvvmNavigation/MvvmNavigation.Shared/FifthPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using BuildIt.Navigation;
using MvvmNavigation.ViewModels;

namespace MvvmNavigation
{
[ViewModel(typeof(FifthViewModel), nameof(InitViewModel))]
public sealed partial class FifthPage
{
partial void InitViewModel();
public FifthViewModel ViewModel => this.ViewModel(() => DataContext as FifthViewModel, () => InitViewModel());

public FifthPage()
{
this.InitializeComponent();
}
}
}
7 changes: 7 additions & 0 deletions MvvmNavigation/MvvmNavigation.Shared/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@
</Interactions:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</Button>
<Button Content="Go To Page 5">
<Interactivity:Interaction.Behaviors>
<Interactions:EventTriggerBehavior EventName="Click">
<builditbehaviors:NavigationMessageAction MessageType="localmessages:PleadTheFifthMessage" />
</Interactions:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
</Button>
</StackPanel>
</Grid>
</Page>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<Compile Include="$(MSBuildThisFileDirectory)App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)FifthPage.xaml.cs">
<DependentUpon>FifthPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)FourthPage.xaml.cs">
<DependentUpon>FourthPage.xaml</DependentUpon>
</Compile>
Expand All @@ -29,6 +32,10 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)FifthPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)FourthPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down

0 comments on commit e7cad72

Please sign in to comment.