Skip to content

Commit

Permalink
Minimum boilerplate to get Routing going
Browse files Browse the repository at this point in the history
  • Loading branch information
anaisbetts committed May 7, 2012
1 parent b3f7c2d commit 02b0364
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
4 changes: 4 additions & 0 deletions AkavacheExplorer/AkavacheExplorer.csproj
Expand Up @@ -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>
Expand Down Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions AkavacheExplorer/MainWindow.xaml
@@ -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>
4 changes: 4 additions & 0 deletions AkavacheExplorer/MainWindow.xaml.cs
Expand Up @@ -11,6 +11,7 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using AkavacheExplorer.ViewModels;

namespace AkavacheExplorer
{
Expand All @@ -19,8 +20,11 @@ namespace AkavacheExplorer
/// </summary>
public partial class MainWindow : Window
{
public AppBootstrapper ViewModel { get; protected set; }

public MainWindow()
{
ViewModel = new AppBootstrapper();
InitializeComponent();
}
}
Expand Down
26 changes: 26 additions & 0 deletions AkavacheExplorer/ViewModels/AppBootstrapper.cs
@@ -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.