Repository navigation
Quick Start
Windows와 .NET 10 SDK에서 첫 WPF 앱을 만듭니다. 아래 파일을 작성하면 호스트 시작, VM 활성화, 창 표시와 종료 정리가 연결됩니다.
dotnet new wpf -n DemoApp -f net10.0
cd DemoApp
dotnet add reference "<저장소 경로>\Gyedo.Wpf\Gyedo.Wpf.csproj"
dotnet add package CommunityToolkit.Mvvm --version 8.4.2<저장소 경로>를 실제 복제한 위치로 바꿉니다. 프로젝트의 대상은 net10.0-windows, UseWPF는 true여야 합니다. Toolkit 특성을 쓰는 앱에는 위처럼 패키지를 직접 참조합니다.
기존 StartupUri를 제거합니다. App.xaml.cs는 public partial class App : Application을 그대로 유지합니다.
<Application x:Class="DemoApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:g="https://github.com/dragonfavors/Gyedo"
xmlns:local="clr-namespace:DemoApp">
<Application.Resources>
<g:ApplicationLoader>
<g:ApplicationLoader.Bootstrapper>
<local:Bootstrapper />
</g:ApplicationLoader.Bootstrapper>
</g:ApplicationLoader>
</Application.Resources>
</Application>기존 XAML 네임스페이스 주소는 그대로 사용합니다.
namespace DemoApp;
public class Bootstrapper : Gyedo.Bootstrapper<ShellViewModel>
{
}기본 루트 VM과 화면 관리 서비스는 자동 등록됩니다. 다른 생성자 의존성은 ConfigureServices에서 등록합니다.
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System.Threading.Tasks;
using Gyedo;
namespace DemoApp;
public partial class ShellViewModel : Screen
{
private readonly IWindowManager windows;
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(GreetCommand))]
private string name = "";
public ShellViewModel(IWindowManager windows)
{
this.windows = windows;
this.DisplayName = "첫 Gyedo 앱";
}
private bool CanGreet() => !string.IsNullOrWhiteSpace(this.Name);
[RelayCommand(CanExecute = nameof(CanGreet))]
private async Task GreetAsync()
{
await this.windows.ShowMessageBoxAsync($"안녕하세요, {this.Name}님!");
}
}기본 MainWindow.xaml과 .xaml.cs를 ShellView.xaml과 .xaml.cs로 바꿉니다. 클래스명과 생성자명도 함께 변경합니다.
ShellView.xaml:
<Window x:Class="DemoApp.ShellView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="200">
<StackPanel Margin="24">
<TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="인사" Command="{Binding GreetCommand}" Margin="0,12,0,0" />
</StackPanel>
</Window>ShellView.xaml.cs:
using System.Windows;
namespace DemoApp;
public partial class ShellView : Window
{
public ShellView() => this.InitializeComponent();
}dotnet run이름을 입력하면 인사 버튼이 활성화됩니다. 호스트가 시작되고 VM 활성화가 끝난 뒤 창을 표시하며, 닫을 때는 화면 정리 후 호스트를 종료합니다.
Main에서 업데이트·권한·단일 실행 검사부터 제어하려면 커스텀 Main을 사용하세요. 두 초기화 방식을 동시에 적용하지 않습니다.
소스 대신 패키지를 쓰려면 저장소에서 직접 빌드합니다.
dotnet pack Gyedo.Core/Gyedo.Core.csproj -c Release -o artifacts/packages
dotnet pack Gyedo.Wpf/Gyedo.Wpf.csproj -c Release -o artifacts/packages
dotnet pack Gyedo.Templates/Gyedo.Templates.csproj -c Release -o artifacts/packages앱의 NuGet 원본에 출력 폴더를 추가합니다. 버전은 프로젝트의 VersionPrefix를 확인하세요. 현재 기본값 0.0.0은 공개 배포 버전이 아닙니다.
dotnet new install ./artifacts/packages/Gyedo.Templates.0.0.0.nupkg
dotnet new gyedo -n MyGyedoApp
dotnet restore MyGyedoApp --source ./artifacts/packages --source 'https://api.nuget.org/v3/index.json'
dotnet run --project MyGyedoApp생성된 앱은 Gyedo.Wpf 패키지를 참조하고, Gyedo.Core는 종속성으로 포함됩니다.