기본 WPF 프로젝트와 다르게 Window를 없앴습니다.
이유는 Window를 보면 그것부터 해야만할 것 같은 생각을 지우기 위해서였죠.
윈도우가 없는 대신 이것은 지켜주셔야합니다. Slate는 *Region 을 이용합니다.
그렇기 때문에 어느 Region에 넣을 지 설정합니다. (아래 소스 참고)
Bootstrapper를 통한 프로젝트 시작
// App.xaml.cs
namespace SlateLab
{
public class SlateBootstrapper : Bootstrapper
{
// RegisterComponent는 전환하고자 하는 Layout 그리고 시작 Layout은 무조건 등록해야합니다.
// Layout(Content)는 무조건 어느 Region에 속하는지 기입해줘야합니다.
protected override void Register(IContainerRegistry containerRegistry)
{
base.Register (containerRegistry);
containerRegistry.RegisterComponent<Content> ();
}
}
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup (e);
var bootstrapper = new SlateBootstrapper ()
.UseMarkupHotReload(this) // XAML을 사용하지 않을 경우 핫리로드를 위해서
필요 .StartLayout<Content>(); // 시작 화면 설정
bootstrapper.Run ();
}
}
}
GlobalUsing의 사용(사용안해도됨)
// GlobalUsing.cs
global using Slate; // 기본
global using Slate.WPF; // 기본
global using Slate.WPF.Markup; // C#을 통한 마크업 라이브러리
global using MarkupChain.WPF; // C#을 통한 마크업 라이브러리
global using System.Windows;
global using System.Windows.Controls;
시작 컴포넌트
using System.Windows.Media;
namespace SlateLab
{
public class Content : Component
{
public override void RegionAttached(object argu)
{
RegionManager.Attach ("Root", this);
}
protected override Visual Build()
=> new Grid ()
{
}
.Size(500, 300);
}
}