Added Autofac

This commit is contained in:
Holger Boerchers 2016-07-25 21:37:43 +02:00
parent 12b3d0c7fb
commit d7919fbe79
7 changed files with 75 additions and 34 deletions

View File

@ -1,8 +1,7 @@
<Application x:Class="MaterialModernWPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MaterialModernWPF"
StartupUri="MainWindow.xaml">
xmlns:local="clr-namespace:MaterialModernWPF">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>

View File

@ -1,17 +1,16 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;
namespace MaterialModernWPF
{
/// <summary>
/// Interaktionslogik für "App.xaml"
/// Interaktionslogik für "App.xaml"
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
new Bootstrapper().Run();
}
}
}
}

View File

@ -0,0 +1,25 @@
using System.Windows;
using Autofac;
using Prism.Autofac;
namespace MaterialModernWPF
{
public class Bootstrapper : AutofacBootstrapper
{
protected override void ConfigureContainerBuilder(ContainerBuilder builder)
{
base.ConfigureContainerBuilder(builder);
builder.RegisterType<Shell>();
//builder.RegisterType<Plugin1.ClassInit>();
}
protected override DependencyObject CreateShell() => Container.Resolve<Shell>();
protected override void InitializeShell()
{
base.InitializeShell();
Application.Current.MainWindow = (Window)Shell;
Application.Current.MainWindow.Show();
}
}
}

View File

@ -38,6 +38,10 @@
<ApplicationIcon>airballoon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Autofac, Version=3.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<HintPath>..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MaterialDesignColors, Version=1.1.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll</HintPath>
<Private>True</Private>
@ -46,12 +50,29 @@
<HintPath>..\packages\MaterialDesignThemes.2.0.0.638\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ModernWpf.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=c99d0cfbea7491ef, processorArchitecture=MSIL">
<HintPath>..\packages\ModernWpf.Core.2.0.0-alpha94\lib\net40-Client\ModernWpf.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Prism, Version=6.1.0.0, Culture=neutral, PublicKeyToken=91a96d2a154366d8, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Core.6.1.0\lib\net45\Prism.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Prism.Autofac.Wpf, Version=6.1.0.0, Culture=neutral, PublicKeyToken=91a96d2a154366d8, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Autofac.6.1.1\lib\net45\Prism.Autofac.Wpf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Prism.Wpf, Version=6.1.0.0, Culture=neutral, PublicKeyToken=91a96d2a154366d8, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Wpf.6.1.0\lib\net45\Prism.Wpf.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
@ -70,20 +91,17 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<Compile Include="Shell.xaml.cs" >
<DependentUpon>Shell.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Bootstrapper.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@ -114,6 +132,12 @@
<ItemGroup>
<Resource Include="airballoon.ico" />
</ItemGroup>
<ItemGroup>
<Page Include="Shell.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -1,10 +1,11 @@
<Window x:Class="MaterialModernWPF.MainWindow"
<Window x:Class="MaterialModernWPF.Shell"
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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:modern="http://modernwpf"
xmlns:prism="http://prismlibrary.com/"
xmlns:system="clr-namespace:System;assembly=mscorlib"
x:Name="Window"
Title="Material Design In XAML Toolkit"
@ -32,9 +33,7 @@
<materialDesign:DialogHost.DialogContent>
<StackPanel Margin="16">
<TextBlock>Tell me your name:</TextBlock>
<TextBox x:Name="FruitTextBox"
Margin="0 8 0 0"
HorizontalAlignment="Stretch" />
<TextBox Margin="0 8 0 0" HorizontalAlignment="Stretch" />
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button Margin="0 8 8 0"
Command="materialDesign:DialogHost.CloseDialogCommand"
@ -102,17 +101,7 @@
ElementName=Window}" />
</DockPanel>
</materialDesign:ColorZone>
<StackPanel Margin="8">
<TextBlock Text="This window demonstrates using core Chrome + external theming lib (ButchersBoy)." TextWrapping="Wrap" />
<Button Content="Hello Button" />
<ComboBox>
<ComboBoxItem Content="A" />
<ComboBoxItem Content="B" />
<ComboBoxItem Content="C" />
<ComboBoxItem Content="D" />
<ComboBoxItem Content="E" />
</ComboBox>
</StackPanel>
<ContentControl prism:RegionManager.RegionName="MainArea" />
</DockPanel>
</materialDesign:DrawerHost>
</materialDesign:DialogHost>

View File

@ -18,9 +18,9 @@ namespace MaterialModernWPF
/// <summary>
/// Interaktionslogik für MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
public partial class Shell : Window
{
public MainWindow()
public Shell()
{
InitializeComponent();
}

View File

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Autofac" version="3.5.2" targetFramework="net452" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net452" />
<package id="MaterialDesignColors" version="1.1.3" targetFramework="net452" />
<package id="MaterialDesignThemes" version="2.0.0.638" targetFramework="net452" />
<package id="ModernWpf.Core" version="2.0.0-alpha94" targetFramework="net452" />
<package id="Prism.Autofac" version="6.1.1" targetFramework="net452" />
<package id="Prism.Core" version="6.1.0" targetFramework="net452" />
<package id="Prism.Wpf" version="6.1.0" targetFramework="net452" />
</packages>