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" <Application x:Class="MaterialModernWPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MaterialModernWPF" xmlns:local="clr-namespace:MaterialModernWPF">
StartupUri="MainWindow.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>

View File

@ -1,10 +1,4 @@
using System; using System.Windows;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace MaterialModernWPF namespace MaterialModernWPF
{ {
@ -13,5 +7,10 @@ namespace MaterialModernWPF
/// </summary> /// </summary>
public partial class App : Application 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> <ApplicationIcon>airballoon.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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"> <Reference Include="MaterialDesignColors, Version=1.1.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll</HintPath> <HintPath>..\packages\MaterialDesignColors.1.1.3\lib\net45\MaterialDesignColors.dll</HintPath>
<Private>True</Private> <Private>True</Private>
@ -46,12 +50,29 @@
<HintPath>..\packages\MaterialDesignThemes.2.0.0.638\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath> <HintPath>..\packages\MaterialDesignThemes.2.0.0.638\lib\net45\MaterialDesignThemes.Wpf.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </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"> <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> <HintPath>..\packages\ModernWpf.Core.2.0.0-alpha94\lib\net40-Client\ModernWpf.Core.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </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" />
<Reference Include="System.Data" /> <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="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -70,20 +91,17 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs"> <Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="MainWindow.xaml.cs"> <Compile Include="Shell.xaml.cs" >
<DependentUpon>MainWindow.xaml</DependentUpon> <DependentUpon>Shell.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Bootstrapper.cs" />
<Compile Include="Properties\AssemblyInfo.cs"> <Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
@ -114,6 +132,12 @@
<ItemGroup> <ItemGroup>
<Resource Include="airballoon.ico" /> <Resource Include="airballoon.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Page Include="Shell.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- 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. 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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:modern="http://modernwpf" xmlns:modern="http://modernwpf"
xmlns:prism="http://prismlibrary.com/"
xmlns:system="clr-namespace:System;assembly=mscorlib" xmlns:system="clr-namespace:System;assembly=mscorlib"
x:Name="Window" x:Name="Window"
Title="Material Design In XAML Toolkit" Title="Material Design In XAML Toolkit"
@ -32,9 +33,7 @@
<materialDesign:DialogHost.DialogContent> <materialDesign:DialogHost.DialogContent>
<StackPanel Margin="16"> <StackPanel Margin="16">
<TextBlock>Tell me your name:</TextBlock> <TextBlock>Tell me your name:</TextBlock>
<TextBox x:Name="FruitTextBox" <TextBox Margin="0 8 0 0" HorizontalAlignment="Stretch" />
Margin="0 8 0 0"
HorizontalAlignment="Stretch" />
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal"> <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button Margin="0 8 8 0" <Button Margin="0 8 8 0"
Command="materialDesign:DialogHost.CloseDialogCommand" Command="materialDesign:DialogHost.CloseDialogCommand"
@ -102,17 +101,7 @@
ElementName=Window}" /> ElementName=Window}" />
</DockPanel> </DockPanel>
</materialDesign:ColorZone> </materialDesign:ColorZone>
<StackPanel Margin="8"> <ContentControl prism:RegionManager.RegionName="MainArea" />
<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>
</DockPanel> </DockPanel>
</materialDesign:DrawerHost> </materialDesign:DrawerHost>
</materialDesign:DialogHost> </materialDesign:DialogHost>

View File

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

View File

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <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="MaterialDesignColors" version="1.1.3" targetFramework="net452" />
<package id="MaterialDesignThemes" version="2.0.0.638" 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="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> </packages>