Permalink
Browse files

Minimum boilerplate to get Routing going

  • Loading branch information...
1 parent b3f7c2d commit 02b0364d79b514ed685cd5c6bf620799d1b2fc2e @paulcbetts committed May 7, 2012
@@ -92,6 +92,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
+ <Compile Include="ViewModels\AppBootstrapper.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@@ -130,6 +131,9 @@
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
+ <ItemGroup>
+ <Folder Include="Views\" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -1,8 +1,7 @@
<Window x:Class="AkavacheExplorer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:Routing="clr-namespace:ReactiveUI.Routing;assembly=ReactiveUI.Routing" x:Name="theWindow"
Title="MainWindow" Height="350" Width="525">
- <Grid>
-
- </Grid>
+ <Routing:RoutedViewHost Router="{Binding Path=ViewModel.Router, ElementName=theWindow}" />
</Window>
@@ -11,6 +11,7 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using AkavacheExplorer.ViewModels;
namespace AkavacheExplorer
{
@@ -19,8 +20,11 @@ namespace AkavacheExplorer
/// </summary>
public partial class MainWindow : Window
{
+ public AppBootstrapper ViewModel { get; protected set; }
+
public MainWindow()
{
+ ViewModel = new AppBootstrapper();
InitializeComponent();
}
}
@@ -0,0 +1,26 @@
+using Ninject;
+using ReactiveUI;
+using ReactiveUI.Routing;
+
+namespace AkavacheExplorer.ViewModels
+{
+ public class AppBootstrapper : ReactiveObject, IScreen
+ {
+ public IRoutingState Router { get; protected set; }
+
+ public AppBootstrapper(IKernel kernel = null, IRoutingState router = null)
+ {
+ kernel = kernel ?? createStandardKernel();
+ router = router ?? new RoutingState();
+
+ RxApp.ConfigureServiceLocator(
+ (t, s) => kernel.Get(t, s), (t, s) => kernel.GetAll(t, s));
+ }
+
+ IKernel createStandardKernel()
+ {
+ var ret = new StandardKernel();
+ return ret;
+ }
+ }
+}

0 comments on commit 02b0364

Please sign in to comment.