1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Added routing to UI project

Added Ninject
Added Fody
This commit is contained in:
SpoinkyNL 2017-12-20 01:00:02 +01:00
parent c2cf86b6b8
commit a3d3a15a88
14 changed files with 288 additions and 51 deletions

View File

@ -1,7 +1,6 @@
<Application x:Class="Artemis.UI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Artemis.UI"
StartupUri="MainWindow.xaml">
<Application.Resources>
@ -46,8 +45,10 @@
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchBrush.Win10" Color="{DynamicResource Primary500}" />
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchMouseOverBrush.Win10" Color="{DynamicResource Primary400}" />
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorCheckedBrush.Win10" Color="{DynamicResource Primary500Foreground}" />
<!-- Some general convertes etc. -->
<BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@ -0,0 +1,59 @@
using System;
using System.Linq;
using Artemis.UI.Ninject;
using Artemis.UI.ViewModels;
using Ninject;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using Splat;
namespace Artemis.UI
{
public class AppBootstrapper : ReactiveObject, IScreen
{
public AppBootstrapper()
{
Router = new RoutingState();
Kernel = new StandardKernel(new ViewsModule());
// Configure the Ninject kernel and set it up as the default for ReactiveUI
SetupNinject(Kernel);
// Update the title on view change
this.WhenAnyValue(x => x.Router.CurrentViewModel)
.Subscribe(o => o.Subscribe(vm => { ViewTitle = vm != null ? vm.UrlPathSegment : ""; }));
// Navigate to the opening page of the application
Router.Navigate.Execute(Kernel.Get<IMainViewModel>());
}
public IKernel Kernel { get; set; }
[Reactive]
public string ViewTitle { get; set; }
public RoutingState Router { get; }
private void SetupNinject(IKernel kernel)
{
// Bind the main screen to IScreen
kernel.Bind<IScreen>().ToConstant(this);
// Set up NInject to do DI
var customResolver = new FuncDependencyResolver(
(service, contract) =>
{
if (contract != null) return kernel.GetAll(service, contract);
var items = kernel.GetAll(service);
var list = items.ToList();
return list;
},
(factory, service, contract) =>
{
var binding = kernel.Bind(service).ToMethod(_ => factory());
if (contract != null) binding.Named(contract);
});
Locator.Current = customResolver;
}
}
}

View File

@ -13,6 +13,8 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -46,11 +48,17 @@
<Reference Include="MaterialDesignThemes.Wpf, Version=2.3.1.953, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
</Reference>
<Reference Include="Ninject, Version=3.3.4.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
<HintPath>..\packages\Ninject.3.3.4\lib\net45\Ninject.dll</HintPath>
</Reference>
<Reference Include="ReactiveUI, Version=7.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\reactiveui-core.7.4.0\lib\Net45\ReactiveUI.dll</HintPath>
</Reference>
<Reference Include="Splat, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Splat.1.4.0\lib\Net45\Splat.dll</HintPath>
<Reference Include="ReactiveUI.Fody.Helpers, Version=2.2.11.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ReactiveUI.Fody.2.2.11\lib\net45\ReactiveUI.Fody.Helpers.dll</HintPath>
</Reference>
<Reference Include="Splat, Version=1.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Splat.1.6.0\lib\Net45\Splat.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
@ -91,6 +99,8 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="AppBootstrapper.cs" />
<Compile Include="Ninject\ViewsModule.cs" />
<Compile Include="ViewModels\MainViewModel.cs" />
<Compile Include="Views\MainView.xaml.cs">
<DependentUpon>MainView.xaml</DependentUpon>
@ -137,7 +147,9 @@
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="App.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Artemis.Storage\Artemis.Storage.csproj">
@ -148,5 +160,21 @@
<ItemGroup>
<Resource Include="Resources\logo-512.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\bow.svg" />
</ItemGroup>
<ItemGroup>
<Folder Include="ViewModels\Interfaces\" />
</ItemGroup>
<ItemGroup>
<None Include="FodyWeavers.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.2.0.7\build\netstandard1.4\Fody.targets" Condition="Exists('..\packages\Fody.2.0.7\build\netstandard1.4\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Fody.2.0.7\build\netstandard1.4\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.2.0.7\build\netstandard1.4\Fody.targets'))" />
</Target>
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<Weavers>
<ReactiveUI />
</Weavers>

View File

@ -1,22 +1,75 @@
<metro:MetroWindow x:Class="Artemis.UI.MainWindow"
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"
xmlns:local="clr-namespace:Artemis.UI"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:views="clr-namespace:Artemis.UI.Views"
mc:Ignorable="d"
GlowBrush="{DynamicResource AccentColorBrush}"
FontFamily="{StaticResource DefaultFont}"
Title="" d:DesignHeight="589.868">
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"
xmlns:metro="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:views="clr-namespace:Artemis.UI.Views"
xmlns:reactiveUi="http://reactiveui.net"
mc:Ignorable="d"
GlowBrush="{DynamicResource AccentColorBrush}"
FontFamily="{StaticResource DefaultFont}"
Title="Artemis"
d:DesignHeight="639.411"
d:DesignWidth="1113.251">
<metro:MetroWindow.Resources>
<DrawingImage x:Key="BowIcon">
<DrawingImage.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="{DynamicResource IdealForegroundColorBrush}"
Geometry="M1518 3378 c-48 -63 -61 -101 -66 -184 -4 -70 -1 -91 27
-170 l31 -89 -27 -20 c-32 -24 -849 -601 -981 -693 l-93 -64 -87 40
c-48 22 -91 37 -95 32 -5 -4 9 -41 29 -83 l37 -75 -28 -24 c-23 -20
-29 -35 -33 -81 l-4 -56 -82 -19 c-109 -25 -109 -41 4 -91 l85 -38 7
-64 c15 -137 90 -1279 85 -1293 -3 -7 -35 -24 -70 -35 -159 -53 -257
-168 -257 -302 0 -35 2 -38 47 -53 54 -18 185 -21 232 -5 29 10 31
14 31 58 0 26 6 56 14 66 13 18 15 18 46 -8 44 -37 78 -35 119 7 l34
35 -17 41 c-9 23 -12 39 -6 35 6 -4 43 -1 83 6 39 6 219 14 398 18
l327 6 113 57 c158 78 256 166 317 282 24 46 27 62 27 152 0 98 -1
103 -41 184 l-42 83 44 69 c24 37 51 68 59 68 9 0 44 -14 78 -32 l62
-31 -93 -44 c-58 -26 -92 -48 -90 -55 9 -27 353 -68 570 -68 108 0
108 0 108 24 0 34 -105 171 -220 286 -122 122 -238 216 -250 204 -6
-6 -1 -42 16 -98 14 -49 23 -91 19 -94 -3 -3 -36 9 -73 27 l-69 33 24
71 c13 39 23 76 23 82 0 6 28 17 63 24 279 58 399 300 314 632 -32
121 -49 155 -134 255 -37 45 -106 126 -152 180 -73 87 -241 326 -241
343 0 3 15 13 32 21 21 10 35 25 40 45 15 60 -16 103 -81 108 -43 3
-39 22 14 74 l45 43 -25 50 c-35 69 -77 114 -130 139 -63 30 -88 27
-117 -11z m215 -835 c188 -279 250 -417 250 -548 0 -133 -74 -214 -243
-265 l-55 -16 -37 -138 c-21 -76 -39 -140 -40 -141 -6 -5 -814 377 -823
390 -6 7 -19 46 -29 86 -10 41 -25 81 -33 91 -8 9 -57 35 -109 59 -52
23 -93 46 -92 51 2 4 233 169 513 366 l510 358 26 -46 c15 -25 88 -136
162 -247z m-1108 -898 c61 21 88 26 107 19 14 -5 204 -92 421 -194 l395
-185 -27 -35 c-15 -19 -53 -72 -84 -117 l-57 -81 30 -90 c39 -117 40
-179 2 -253 -45 -90 -147 -145 -347 -189 -71 -15 -435 -59 -600 -73 l
-29 -2 -37 540 c-20 297 -40 581 -43 632 l-7 92 98 -46 97 -46 81 28z" />
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</metro:MetroWindow.Resources>
<metro:MetroWindow.LeftWindowCommands>
<metro:WindowCommands>
<!-- Make the window title dissapear by providing an empty overwrite of WindowCommands -->
</metro:WindowCommands>
</metro:MetroWindow.LeftWindowCommands>
<metro:MetroWindow.IconTemplate>
<DataTemplate>
<Grid Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Background="Transparent"
RenderOptions.BitmapScalingMode="HighQuality"
Margin="0,0,-10,0">
<Image Source="{DynamicResource BowIcon}"
Stretch="Uniform"
Margin="6" />
</Grid>
</DataTemplate>
</metro:MetroWindow.IconTemplate>
<materialDesign:DialogHost Identifier="RootDialog">
<materialDesign:DrawerHost IsLeftDrawerOpen="{Binding ElementName=MenuToggleButton, Path=IsChecked}">
<materialDesign:DrawerHost.LeftDrawerContent>
<DockPanel MinWidth="212">
<ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}"
<ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}"
DockPanel.Dock="Top"
HorizontalAlignment="Right" Margin="16"
IsChecked="{Binding ElementName=MenuToggleButton, Path=IsChecked, Mode=TwoWay}" />
@ -34,30 +87,24 @@
Mode="PrimaryMid" DockPanel.Dock="Top">
<DockPanel>
<ToggleButton Style="{StaticResource MaterialDesignHamburgerToggleButton}" IsChecked="False"
x:Name="MenuToggleButton"/>
<materialDesign:PopupBox DockPanel.Dock="Right" PlacementMode="BottomAndAlignRightEdges" StaysOpen="False">
x:Name="MenuToggleButton" />
<materialDesign:PopupBox DockPanel.Dock="Right" PlacementMode="BottomAndAlignRightEdges"
StaysOpen="False">
<StackPanel>
<Button Content="Hello World" />
<Button Content="Nice Popup" />
<Button Content="Can't Touch This" IsEnabled="False" />
<Separator/>
<Separator />
<Button Content="Goodbye" />
</StackPanel>
</materialDesign:PopupBox>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="22" Text="Artemis"/>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="22" Text="{Binding ViewTitle}" />
</DockPanel>
</materialDesign:ColorZone>
<views:MainView></views:MainView>
<reactiveUi:RoutedViewHost Router="{Binding Router}"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch" />
</DockPanel>
</materialDesign:DrawerHost>
</materialDesign:DialogHost>
</metro:MetroWindow>
</metro:MetroWindow>

View File

@ -10,6 +10,11 @@ namespace Artemis.UI
public MainWindow()
{
InitializeComponent();
AppBootstrapper = new AppBootstrapper();
DataContext = AppBootstrapper;
}
public AppBootstrapper AppBootstrapper { get; }
}
}
}

View File

@ -0,0 +1,13 @@
using Artemis.UI.ViewModels;
using Ninject.Modules;
namespace Artemis.UI.Ninject
{
public class ViewsModule : NinjectModule
{
public override void Load()
{
Bind<IMainViewModel>().To<MainViewModel>();
}
}
}

View File

@ -60,6 +60,16 @@ namespace Artemis.UI.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Byte[].
/// </summary>
internal static byte[] bow {
get {
object obj = ResourceManager.GetObject("bow", resourceCulture);
return ((byte[])(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -118,6 +118,9 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="bow" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bow.svg;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="logo_512" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logo-512.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="242.000000pt" height="341.000000pt" viewBox="0 0 242.000000 341.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.15, written by Peter Selinger 2001-2017
</metadata>
<g transform="translate(0.000000,341.000000) scale(0.100000,-0.100000)"
fill="#ffffff" stroke="none">
<path d="M46 3388 l-48 -22 5 -47 c15 -121 99 -212 249 -268 l75 -28 1 36 c1
20 4 71 8 114 3 46 2 77 -3 77 -16 0 -33 49 -33 94 0 40 -3 45 -31 55 -54 19
-168 13 -223 -11z"/>
<path d="M378 3281 c-24 -19 -25 -26 -31 -173 -3 -84 -24 -409 -47 -723 -22
-313 -44 -628 -48 -700 -5 -71 -10 -111 -11 -88 l-1 42 -85 -37 c-46 -20 -85
-42 -85 -47 0 -6 38 -19 85 -29 l85 -19 0 -43 c0 -57 14 -92 44 -105 l25 -12
-40 -79 c-22 -44 -39 -81 -37 -83 5 -5 472 215 484 228 6 7 21 51 34 98 l22
86 615 288 c337 158 615 286 617 284 2 -2 -9 -49 -25 -103 -16 -55 -27 -102
-24 -104 7 -8 144 108 235 198 92 91 230 263 230 286 0 27 -334 14 -562 -22
-60 -10 -108 -20 -108 -24 0 -4 45 -27 100 -52 l100 -45 -172 -81 c-684 -321
-1017 -476 -1042 -485 -24 -8 -44 -5 -110 18 l-82 28 -98 -46 c-55 -26 -101
-45 -103 -43 -5 5 87 1349 93 1355 2 2 4 -12 4 -31 0 -29 4 -37 23 -41 12 -4
132 -18 267 -32 333 -35 482 -69 585 -133 62 -38 86 -63 111 -117 33 -69 31
-135 -6 -247 l-30 -89 77 -110 c42 -61 80 -112 84 -115 4 -2 55 18 113 45
l105 50 -49 73 -48 74 41 84 c41 81 42 86 42 184 0 96 -2 104 -34 163 -34 64
-118 154 -184 199 -21 14 -81 46 -135 72 l-97 47 -325 6 c-179 4 -358 12 -397
18 -40 7 -78 9 -84 6 -6 -4 -20 -21 -31 -39 -24 -37 -22 -30 16 57 l29 68 -28
29 c-34 35 -71 39 -107 11z"/>
<path d="M1730 2035 c-52 -25 -99 -46 -103 -48 -5 -1 8 -66 28 -144 l37 -141
45 -12 c115 -28 217 -106 244 -186 47 -138 -16 -306 -236 -635 -74 -110 -147
-221 -162 -246 -26 -45 -26 -46 -7 -60 34 -27 98 -53 129 -52 27 0 37 11 103
112 40 62 105 151 145 198 39 48 110 131 155 185 100 119 116 148 149 273 32
125 34 267 6 357 -47 145 -150 232 -314 266 -34 7 -63 17 -65 23 -2 5 -13 43
-24 83 -12 39 -25 72 -28 72 -4 0 -50 -20 -102 -45z"/>
<path d="M450 1273 l-35 -15 25 -17 c13 -9 123 -86 245 -172 121 -85 360 -254
530 -374 171 -120 352 -251 403 -292 79 -62 98 -72 120 -67 61 15 79 42 64 99
-8 27 -17 33 -113 65 -103 35 -109 39 -641 413 -296 207 -543 377 -550 376 -7
0 -29 -8 -48 -16z"/>
<path d="M1486 380 c-29 -90 -34 -190 -12 -253 17 -46 65 -117 85 -125 20 -8
117 45 147 81 14 16 36 51 49 77 l24 48 -44 45 c-25 24 -45 53 -45 64 0 13
-26 38 -77 75 -43 30 -83 58 -89 61 -7 4 -21 -22 -38 -73z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -4,18 +4,26 @@ using ReactiveUI;
namespace Artemis.UI.ViewModels
{
public class MainViewModel : ReactiveObject
public class MainViewModel : ReactiveObject, IMainViewModel
{
public ReactiveCommand OpenUrl { get; }
public MainViewModel()
public MainViewModel(IScreen screen)
{
HostScreen = screen;
OpenUrl = ReactiveCommand.CreateFromTask<string>(OpenUrlAsync);
}
public IScreen HostScreen { get; }
public string UrlPathSegment => "Home";
public ReactiveCommand OpenUrl { get; }
private async Task OpenUrlAsync(string url)
{
await Task.Run(() => Process.Start(url));
}
}
}
public interface IMainViewModel : IRoutableViewModel
{
ReactiveCommand OpenUrl { get; }
}
}

View File

@ -139,10 +139,12 @@
</StackPanel>
</Grid>
</ScrollViewer>
<materialDesign:PopupBox Style="{StaticResource MaterialDesignMultiFloatingActionPopupBox}"
<!-- PopupBox could be nice in the future when we actually have some stuff to send ppl to -->
<!--<materialDesign:PopupBox Style="{StaticResource MaterialDesignMultiFloatingActionPopupBox}"
HorizontalAlignment="Right" VerticalAlignment="Bottom"
Margin="32" Grid.Row="1">
<StackPanel>
--><!-- add the visibility binding https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/issues/723 --><!--
<StackPanel Visibility="{Binding Path=IsPopupOpen, ElementName=MyPopupBox, Converter={StaticResource BoolToVisibilityConverter}}">
<Button ToolTip="GitHub" Command="{Binding OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis">
<materialDesign:PackIcon Kind="GithubCircle" Height="20" Width="20" />
</Button>
@ -152,7 +154,7 @@
<materialDesign:PackIcon Kind="Twitter" />
</Button>
<Button ToolTip="Chat" Command="{Binding OpenUrl}" CommandParameter="https://github.com/SpoinkyNL/Artemis">
<!-- mix up the colours by brinking in a named palette (see merged dictionaries at top) -->
--><!-- mix up the colours by brinking in a named palette (see merged dictionaries at top) --><!--
<Button.Background>
<SolidColorBrush Color="{StaticResource GreenPrimary500}" />
</Button.Background>
@ -178,6 +180,6 @@
<materialDesign:PackIcon Kind="Gift" />
</Button>
</StackPanel>
</materialDesign:PopupBox>
</materialDesign:PopupBox>-->
</Grid>
</UserControl>

View File

@ -1,20 +1,30 @@
using System.Windows.Controls;
using System.Windows;
using System.Windows.Controls;
using Artemis.UI.ViewModels;
using ReactiveUI;
namespace Artemis.UI.Views
{
/// <summary>
/// Interaction logic for MainView.xaml
/// </summary>
public partial class MainView : UserControl
public partial class MainView : UserControl, IViewFor<IMainViewModel>
{
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel", typeof(IMainViewModel), typeof(MainView), new PropertyMetadata(null));
public MainView()
{
ViewModel = new MainViewModel();
InitializeComponent();
DataContext = ViewModel;
this.WhenAnyValue(x => x.ViewModel).BindTo(this, x => x.DataContext);
}
public MainViewModel ViewModel { get; set; }
object IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (IMainViewModel) value;
}
public IMainViewModel ViewModel { get; set; }
}
}
}

View File

@ -1,10 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Fody" version="2.0.7" targetFramework="net461" developmentDependency="true" />
<package id="MahApps.Metro" version="1.5.0" targetFramework="net461" />
<package id="MaterialDesignColors" version="1.1.3" targetFramework="net461" />
<package id="MaterialDesignThemes" version="2.3.1.953" targetFramework="net461" />
<package id="MaterialDesignThemes.MahApps" version="0.0.11" targetFramework="net461" />
<package id="Ninject" version="3.3.4" targetFramework="net461" />
<package id="reactiveui" version="7.4.0" targetFramework="net461" />
<package id="ReactiveUI.Fody" version="2.2.11" targetFramework="net461" />
<package id="reactiveui-core" version="7.4.0" targetFramework="net461" />
<package id="Rx-Core" version="2.2.5" targetFramework="net461" />
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net461" />
@ -12,5 +15,5 @@
<package id="Rx-Main" version="2.2.5" targetFramework="net461" />
<package id="Rx-PlatformServices" version="2.2.5" targetFramework="net461" />
<package id="Rx-XAML" version="2.2.5" targetFramework="net461" />
<package id="Splat" version="1.4.0" targetFramework="net461" />
<package id="Splat" version="1.6.0" targetFramework="net461" />
</packages>