1. 기본젝트 구성생성 (NewsAggregtor.Shell.csproj)

image

(같이 웹사이트도 생성)

CAL 관련 참조파일 참조

Bootstrapper.cs 생성

using Microsoft.Practices.Composite.UnityExtensions;
using Microsoft.Practices.Composite.Modularity;
namespace NewsAggregtor.Shell
{
    public class Bootstrapper :UnityBootstrapper
    {
        protected override DependencyObject CreateShell()
        {
            Shell shell = new Shell();
            Application.Current.RootVisual = shell;
            return shell;
        }

        protected override IModuleCatalog GetModuleCatalog()
        {
            return base.GetModuleCatalog();
        }
    }
}

2.Shell.xaml 페이지 생성

App.xaml 페이지 수정

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //this.RootVisual = new Page();
            new Bootstrapper().Run();
        }

 

 

2.모듈구성 프로젝트 생성 (NewAggregtor.Digg.csproj)

image

CAL 관련 참조파일 참조

DiggModule.cs 파일 생성

using Microsoft.Practices.Composite.Modularity;


namespace NewsAggregtor.Digg
{
    public class DiggModule : IModule
    {

        #region IModule 멤버

        public void Initialize()
        {
           
        }

        #endregion
    }
}

-------------------------------------------------------------------------------------------------------------------

모듈프로젝트 생성후 NewsAggregtor.Shell.csproj 프로젝트에서

모듈프로젝트 참조

image

 

NewsAggregtor.Shell.csproj  에서

모듈관련 프로젝트 참조후 GetModuleCatalog() 메소드 모듈 로드로 수정

using Microsoft.Practices.Composite.UnityExtensions;
using Microsoft.Practices.Composite.Modularity;
namespace NewsAggregtor.Shell
{
    public class Bootstrapper :UnityBootstrapper
    {
        protected override DependencyObject CreateShell()
        {
            Shell shell = new Shell();
            Application.Current.RootVisual = shell;
            return shell;
        }

        protected override IModuleCatalog GetModuleCatalog()
        {
            ModuleCatalog catalog = new ModuleCatalog();
            catalog.AddModule( typeof( NewsAggregtor.Digg.DiggModule) );
            return catalog;
        }
    }
}

실행해서 오류 안나면 일단 성공~

image

 

두번째 Createing a Modular

image

image

 

DiggSearchResult.xaml 페이지 추가

<UserControl x:Class="NewsAggregtor.Digg.DiggSearchResult"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <TextBlock>DiggSearchResult</TextBlock>
    </Grid>
</UserControl>

DiggSearchResultView.xaml 페이지 추가

<UserControl x:Class="NewsAggregtor.Digg.DiggSearchResultView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <TextBlock>DiggSearchResultView</TextBlock>
    </Grid>
</UserControl>

 

NewAggregtor.Digg.csproj 의 DiggModule.cs 수정

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Regions;
namespace NewsAggregtor.Digg
{
    public class DiggModule : IModule
    {

        #region IModule 멤버

        public void Initialize()
        {
            //Shell.xaml의 ResultRegion 이름을 찾아서 DiggSearchResultView.xaml 이 등록된다
            regionManager.RegisterViewWithRegion("ResultRegion", typeof(NewsAggregtor.Digg.DiggSearchResultView));
        }

        #endregion

        private IRegionManager regionManager;
        public DiggModule(IRegionManager regionManager )
        {
            this.regionManager = regionManager;
        }


    }
}

 

 

NewsAggregtor.Shell.csproj 의 Shell.xaml 파일수정

네임스페이스 추가

xmlns:Regions="clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation"

 

<UserControl xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"  x:Class="NewsAggregtor.Shell.Shell"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:Regions="clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
    	<Grid.RowDefinitions>
    		<RowDefinition Height="0.197*"/>
    		<RowDefinition Height="0.803*"/>
    	</Grid.RowDefinitions>
        
        <ContentControl Regions:RegionManager.RegionName="searchRegion" Background="{x:Null}"/>
        <basics:TabControl Regions:RegionManager.RegionName="searchResult"></basics:TabControl>
    </Grid>
</UserControl>

 

모듈등록

일단 Shell.xaml 페이지에

xmlns:Regions="clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation"

추가하고

<ContentControl Regions:RegionManager.RegionName="searchRegion" Background="{x:Null}"/>
<basics:TabControl Regions:RegionManager.RegionName="ResultRegion"></basics:TabControl>

임의의 이름을 준다 나중에 모듈 올릴때 저 이름으로 찾아간다

 

image

잘 나타면 끗~

+ Recent posts