간단한 모듈등록하기
실버라이트 프로젝트
이 프로젝트에서는 추가로
DLL을 추가해야합니다.
Shell.xaml 는 맨처음 실행되는 페이지 입니다.
<UserControl x:Class="HelloWorld.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">
<ItemsControl Name="MainRegion" Regions:RegionManager.RegionName="MainRegion"/>
</UserControl>
Bootstrapper.cs
using System.Windows;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.UnityExtensions;
namespace HelloWorld
{
public class Bootstrapper : UnityBootstrapper
{
protected override DependencyObject CreateShell()
{
Shell shell = Container.Resolve<Shell>();
Application.Current.RootVisual = shell;
return shell;
}
protected override IModuleCatalog GetModuleCatalog()
{
ModuleCatalog catalog = new ModuleCatalog()
.AddModule(typeof(HelloWorldModule.HelloWorldModule));
return catalog;
}
}
}
웹프로젝트
실버라이트 실행하는 웹페이지(이프로젝트는 크게 의미없습니다 )
모듈 프로젝트 CALSilverlightModule.csproj
모듈 프로젝트는 (추가로 Microsoft.Practices.Composite 참조해야합니다).
모듈프로젝트에서 아래의 코드를 삽입합니다.
HelloWorldModule.cs
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.Composite.Regions;
namespace HelloWorldModule
{
public class HelloWorldModule : IModule
{
private readonly IRegionManager regionManager;
public HelloWorldModule(IRegionManager regionManager)
{
this.regionManager = regionManager;
}
public void Initialize()
{
regionManager.RegisterViewWithRegion("MainRegion", typeof(Views.HelloWorldView));
}
}
}
HelloWorldView.xaml
<UserControl x:Class="HelloWorldModule.Views.HelloWorldView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<Grid x:Name="LayoutRoot" Background="White">
<TextBlock Text="Hello World" Foreground="Green"
HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Calibri" FontSize="24"
FontWeight="Bold"></TextBlock>
</Grid>
</UserControl>'WPF' 카테고리의 다른 글
| 데이터 삽입,수정,삭제 방법(ADO.NET 데이터 서비스/Silverlight) (0) | 2009.05.28 |
|---|---|
| Presentation Model. (0) | 2009.05.27 |
| [CAL] 간단한 모듈 구성 (0) | 2009.05.12 |
| [CAL] Presentation Model (0) | 2009.05.06 |
| CAL Development Activities (0) | 2009.04.29 |
| Silverlight Toolkit 와 Deep Zoom Composer 다운로드 (0) | 2009.04.24 |
| Prism: patterns & practices Composite Application Guidance for WPF and Silverlight site (0) | 2009.04.22 |
| Video How to: Create a C# WPF Application (0) | 2009.04.20 |
| ResizeGrip - Resizing (Mostly Custom) Windows (0) | 2009.04.20 |
| WPF로 복합 응용 프로그램을 작성하기 위한 패턴 (0) | 2009.04.20 |