Shell框架XECA

shell.xaml主要起到是一个容器或壳的作用

<Window x:Class="XECA.Shell"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       
        xmlns:inf="clr-namespace:MyGlobal.Infrustructure;assembly=MyGlobal.Infrustructure"
        xmlns:prism="http://prismlibrary.com/"
        xmlns:Controls="clr-namespace:MyGlobal.Infrustructure.Controls;assembly=MyGlobal.Infrustructure"
        Title="工作平台" Height="300" Width="300" Background="{StaticResource myGraybrush}">
 
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Border Margin="5" Grid.Row="1" CornerRadius="5,5,5,5" BorderBrush="Black" BorderThickness="1">
            <Grid  Width="auto" Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.15*"></ColumnDefinition>
                    <ColumnDefinition Width="0.85*"></ColumnDefinition>
                </Grid.ColumnDefinitions>

<!--<Controls:RoundedBox Margin="10" />-->
                <Border Grid.Column="0" CornerRadius="10"  Background="{StaticResource myGraybrush}" BorderBrush="#193441" BorderThickness="1" Margin="3" Padding="1">
                    <ItemsControl prism:RegionManager.RegionName="{x:Static inf:RegionNames.MenuRegion }"/>
                </Border>

<Border Grid.Column="1" CornerRadius="10" Background="#FCFFf5" BorderBrush="#193441" BorderThickness="0" Margin="1" Padding="0">
                    <Grid x:Name="ContentGrid"   Grid.Row="1" RenderTransformOrigin="0.5,0.5">
                        <Grid.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Grid.RenderTransform>
                        <Border BorderThickness="1" Width="auto" Height="auto" CornerRadius="10,10,10,10" BorderBrush="Black" >
                            <Controls:AnimatedTabControl
                                        x:Name="TabName"
                                        SelectedIndex="0" 
                                        VerticalAlignment="Stretch"
                                        ItemContainerStyle="{StaticResource ShellTabItemStyle}"
                                        Background="{StaticResource headerBarBG}"
                                        prism:RegionManager.RegionName="{x:Static inf:RegionNames.MCWrapRegion}"
                                        AutomationProperties.AutomationId="TabId" />
                        </Border>
                    </Grid>
                </Border>

</Grid>

</Border>
        <StackPanel Orientation="Horizontal">
            <Label HorizontalAlignment="Left" Margin="10,0,0,0" Width="Auto" Content="U-Project" FontWeight="Bold" Foreground="#fff" FontSize="24" FontFamily="Corbel"/>
          
        </StackPanel>
    </Grid>

</Window>

这里涉及两个关键技术点,一个是style的全局共享,另一个是采用AnimatedTabControl控件

App.config删除起始访问设置

<Application x:Class="XECA.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:XECA">  
</Application>

Bootstrap.cs代码

using Prism.Unity;
using System.Windows;
using Microsoft.Practices.Unity;
using Prism.Modularity;
 
using XECA.Views;
using Prism.Mef;
using System.ComponentModel.Composition.Hosting;
using MyGlobal.Infrustructure.Behaviors;
using System;
using MyGlobal.Infrustructure;
using Prism.Logging;
using EntityFW;
using TestTabItems;

namespace XECA
{
     [CLSCompliant(false)]
    public partial class Bootstrapper : MefBootstrapper//采用MefBootstrapper
    {

//程序运行日志管理
        private readonly EnterpriseLibraryLoggerAdapter _logger = new EnterpriseLibraryLoggerAdapter();

protected override ILoggerFacade CreateLogger()
        {
            return _logger;
        }
        protected override void ConfigureAggregateCatalog()
        {
            base.ConfigureAggregateCatalog();
            this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Bootstrapper).Assembly));
            this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(RICommands).Assembly));
           
           
            this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(EntityFWModule).Assembly));
            this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(TabTestModule).Assembly));
            //业务模块采用目录catlog加载方式,即后续业务模块开发完成,将DLL扔到目录下即可

this.AggregateCatalog.Catalogs.Add(new DirectoryCatalog("../../Modules"));
        }

protected override void ConfigureContainer()
        {
            base.ConfigureContainer();
        }

protected override void InitializeShell()
        {
            base.InitializeShell();

Application.Current.MainWindow = (Window)this.Shell;
            Application.Current.MainWindow.Show();
        }

protected override Prism.Regions.IRegionBehaviorFactory ConfigureDefaultRegionBehaviors()
        {
            var factory = base.ConfigureDefaultRegionBehaviors();

factory.AddIfMissing("AutoPopulateExportedViewsBehavior", typeof(AutoPopulateExportedViewsBehavior));

return factory;
        }

protected override DependencyObject CreateShell()
        {
            DependencyObject x= this.Container.GetExportedValue<Shell>();
            return x;
        }
    }
}

05-02 05:14