第527篇-Prism学习系列3_Modularity

在Prism中,一个非常普遍的方法是把各个不同的Business模块化,用Module的机制可以很好的解决这个问题。

Module支持即时加载.

   /// 
    /// A module for the quickstart.
    /// 
    [ModuleExport(typeof(ModuleD))]
    public class ModuleD : IModule
    {
        private readonly IModuleTracker moduleTracker;

        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// The module tracker.
        [ImportingConstructor]
        public ModuleD(IModuleTracker moduleTracker)
        {
            if (moduleTracker == null)
            {
                throw new ArgumentNullException("moduleTracker");
            }

            this.moduleTracker = moduleTracker;
            this.moduleTracker.RecordModuleConstructed(WellKnownModuleNames.ModuleD);
        }

        /// 
        /// Notifies the module that it has be initialized.
        /// 
        public void Initialize()
        {
            this.moduleTracker.RecordModuleInitialized(WellKnownModuleNames.ModuleD);
        }
    }

顺便说一下Data Trigger:

 <i:Interaction.Triggers>
                
                
                
                <ei:DataTrigger Binding="{Binding ElementName=ModuleStatusTextBlock, Path=Text}" Value="NotStarted">
                    <ei:ChangePropertyAction PropertyName="Background" 
                                             TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                             Value="{StaticResource ModuleControl.NotStarted.BackgroundBrush-Simple}"/>
                    <ei:ChangePropertyAction PropertyName="Foreground" 
                                             TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                             Value="{StaticResource ModuleControl.NotStarted.ForegroundBrush-Simple}"/>
                    <ei:ChangePropertyAction PropertyName="BorderBrush"
                                             TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                                             Value="{StaticResource ModuleControl.NotStarted.BorderBrush-Simple}"/>
                    <ei:ChangePropertyAction PropertyName="FontSize" 
                                             TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}" 
                                             Value="12"/>
                ei:DataTrigger>

下载地址:ModularityWithMef

转载于:https://www.cnblogs.com/shanghaijimzhou/archive/2013/03/31/2992386.html

你可能感兴趣的:(ui)