iconDreamine
← 목록

Dreamine.MVVM.Wpf

stablev1.0.3

WPF 진입점 통합 패키지 — App 부트스트랩, Window 생명주기 관리.

#bootstrap#dreamine#mvvm#runtime#wpf
TFM net8.0-windowsPackage Dreamine.MVVM.Wpf참조 Dreamine.MVVM.Core, Dreamine.MVVM.Locators, Dreamine.MVVM.Locators.Wpf

Dreamine.MVVM.Wpf

Dreamine MVVM 프레임워크를 위한 WPF 전용 부트스트랩 및 런타임 통합 레이어입니다.

➡️ English Version

개요

Dreamine.MVVM.Wpf 는 Dreamine MVVM 애플리케이션에서 필요한 WPF 전용 시작 처리와 런타임 연결 로직을 담당합니다.

이 패키지의 책임은 다음과 같습니다.

  • View ↔ ViewModel 자동 매핑 등록
  • DMContainer 기반 자동 DI 등록
  • View 로드 시 DataContext 자동 연결
  • 현재 로드된 Window의 Region 기반 navigator 선택적 등록
  • 플랫폼 중립 라이브러리와 WPF 런타임 책임 분리

왜 이 패키지가 필요한가

Dreamine.MVVM.Core 는 가능한 한 플랫폼 중립적으로 유지하는 것이 맞습니다.

하지만 FrameworkElement.Loaded, EventManager, View 런타임 바인딩 같은 요소는 명백한 WPF 전용 책임입니다. 이 책임들을 Core에 두면 계층이 흐려지고 대상 프레임워크도 WPF에 묶입니다.

그래서 WPF 전용 책임은 Dreamine.MVVM.Wpf 로 분리하는 구조가 맞습니다.

주요 타입

DreamineAppBuilder

DreamineAppBuilder 는 WPF 애플리케이션 시작 시 Dreamine MVVM 런타임을 초기화하는 진입점입니다.

내부적으로 다음 작업을 수행합니다.

  1. View ↔ ViewModel 매핑 등록
  2. DMContainer 자동 등록 수행
  3. WPF Loaded 이벤트를 연결하여 필요한 경우 DataContext 자동 주입
  4. 옵션이 켜져 있으면 현재 Window의 Region을 기준으로 INavigator 등록

자동 navigator 등록을 사용하는 경우, Window가 로드될 때 해당 Window의 Region이 전역 INavigator 등록을 갱신합니다. 그래서 이전에 로드된 Window의 Region에 계속 고정되는 상황을 피할 수 있습니다.

사용 방법

애플리케이션 시작 시점에 DreamineAppBuilder.Initialize(...) 를 한 번 호출하면 됩니다.

using System.Reflection;
using System.Windows;
using Dreamine.MVVM.Wpf;

namespace SampleApp;

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);

        DreamineAppBuilder.Initialize(Assembly.GetExecutingAssembly());
    }
}

프로젝트 역할 분리 기준

권장 책임 분리는 다음과 같습니다.

  • Dreamine.MVVM.Core
    • 컨테이너
    • 커맨드 인프라
    • 플랫폼 중립 MVVM 런타임 지원
  • Dreamine.MVVM.ViewModels
    • ViewModelBase
  • Dreamine.MVVM.Locators
    • ViewModel 매핑 및 해석 로직
  • Dreamine.MVVM.Wpf
    • WPF 시작 처리 / 부트스트랩 / 런타임 연결

대상 프레임워크

  • net8.0-windows
  • WPF 사용

라이선스

MIT License

구조 다이어그램

classDiagram
    class RelayCommand {
        -Action~object~ _execute
        -Predicate~object~ _canExecute
        +Execute(object) void
        +CanExecute(object) bool
        +RaiseCanExecuteChanged() void
    }
    class AsyncRelayCommand {
        -Func~Task~ _execute
        +IsRunning bool
        +IsCancellationRequested bool
        +ExecuteAsync() Task
        +Cancel() void
    }
    class WpfNavigationService {
        -Frame _frame
        +NavigateTo~T~() void
        +GoBack() void
        +CanGoBack bool
    }
    class WpfDialogService {
        +ShowAsync~T~() Task
        +ConfirmAsync(string) Task~bool~
        +AlertAsync(string) Task
    }
    class IRelayCommand {
        <<interface>>
    }
    class IAsyncRelayCommand {
        <<interface>>
    }
    IRelayCommand <|.. RelayCommand
    IAsyncRelayCommand <|.. AsyncRelayCommand
    RelayCommand <|-- AsyncRelayCommand

API 문서

타입

DreamineAppBuilder

\if KO Dreamine WPF 애플리케이션 초기화를 담당합니다. \endif \if EN Encapsulates dreamine app builder functionality and related state. \endif

DreamineWpfOptions

\if KO Dreamine Wpf Options 기능과 관련 상태를 캡슐화합니다. \endif \if EN Provides configuration options for the Dreamine WPF runtime bootstrap process. \endif

ViewManager

\if KO View Manager 기능과 관련 상태를 캡슐화합니다. \endif \if EN Resolves and displays WPF Views based on ViewModel types. Custom view types are supported by registering implementations via . \endif

WindowStateService

\if KO Window State Service 기능과 관련 상태를 캡슐화합니다. \endif \if EN Tracks WPF window open states in memory. \endif

WpfDialogService

\if KO Wpf Dialog Service 기능과 관련 상태를 캡슐화합니다. \endif \if EN Default WPF implementation of backed by . \endif

DreamineAppBuilder

AttachViewModelIfExists Method

\if KO WPF FrameworkElement의 Loaded 이벤트에서 호출되는 핸들러입니다. View의 DataContext가 비어 있을 경우, ViewModelLocator를 통해 ViewModel을 자동 연결합니다. \endif \if EN Attaches the behavior to a target object. \endif

sender— \if KO 이벤트가 발생한 View 인스턴스입니다. \endif \if EN The object that raised the event. \endif
e— \if KO 라우팅 이벤트 인자입니다. \endif \if EN Contains data associated with the event. \endif
Initialize Method

\if KO Dreamine MVVM WPF 런타임을 기본 옵션으로 초기화합니다. \endif \if EN Performs the initialize operation. \endif

rootAssembly— \if KO View, ViewModel, Model, Event, Manager 등의 자동 등록 및 매핑 대상으로 사용할 루트 어셈블리입니다. \endif \if EN The value used for root assembly. \endif
Initialize Method

\if KO Dreamine MVVM WPF 런타임을 지정한 옵션으로 초기화합니다. \endif \if EN Performs the initialize operation. \endif

rootAssembly— \if KO View, ViewModel, Model, Event, Manager 등의 자동 등록 및 매핑 대상으로 사용할 루트 어셈블리입니다. \endif \if EN The value used for root assembly. \endif
options— \if KO WPF 런타임 초기화 옵션입니다. \endif \if EN The options that configure the operation. \endif
RegisterAutoNavigatorHandlerOnce Method

\if KO Window Loaded 시점에 지정된 RegionName을 찾아 INavigator를 자동 등록하는 핸들러를 한 번만 등록합니다. \endif \if EN Performs the register auto navigator handler once operation. \endif

defaultRegionName— \if KO 기본 Region 이름입니다. \endif \if EN The value used for default region name. \endif
RegisterDefaultServices Method

\if KO Dreamine WPF 기본 서비스를 등록합니다. 이미 등록된 서비스는 덮어쓰지 않습니다. \endif \if EN Performs the register default services operation. \endif

options— \if KO 동작을 구성하는 설정입니다. \endif \if EN The options that configure the operation. \endif
RegisterDefaultViewModelResolver Method

\if KO Register Default View Model Resolver 작업을 수행합니다. \endif \if EN Registers the default ViewModel resolver used by ViewModelLocator. \endif

RegisterGlobalAutoWireHandlerOnce Method

\if KO WPF FrameworkElement Loaded 이벤트의 전역 ViewModel 자동 주입 핸들러를 한 번만 등록합니다. \endif \if EN Performs the register global auto wire handler once operation. \endif

RegisterNavigatorFromWindow Method

\if KO 지정한 Window 내부에서 RegionName이 일치하는 ContentControl을 찾아 INavigator를 등록합니다. \endif \if EN Performs the register navigator from window operation. \endif

window— \if KO Region을 찾을 대상 Window입니다. \endif \if EN The value used for window. \endif
regionName— \if KO Region 이름입니다. \endif \if EN The value used for region name. \endif
_autoNavigatorHandlerRegistered Field

\if KO auto Navigator Handler Registered 값을 보관합니다. \endif \if EN Stores the auto navigator handler registered value. \endif

_globalAutoWireHandlerRegistered Field

\if KO global Auto Wire Handler Registered 값을 보관합니다. \endif \if EN Stores the global auto wire handler registered value. \endif

SyncRoot Field

\if KO Sync Root 값을 보관합니다. \endif \if EN Stores the sync root value. \endif

DreamineWpfOptions

CreateDefault Method

\if KO Default 값을 생성합니다. \endif \if EN Gets the default Dreamine WPF options. \endif

반환: \if KO Create Default 작업에서 생성한 결과입니다. \endif \if EN A new options instance with safe defaults. \endif

DefaultRegionName Property

\if KO Default Region Name 값을 가져오거나 설정합니다. \endif \if EN Gets or sets the default region name used for automatic navigator registration. \endif

EnableAutoNavigatorRegistration Property

\if KO Enable Auto Navigator Registration 값을 가져오거나 설정합니다. \endif \if EN Gets or sets a value indicating whether Dreamine should automatically register an INavigator from the default region. \endif

EnableGlobalAutoWireOnLoaded Property

\if KO Enable Global Auto Wire On Loaded 값을 가져오거나 설정합니다. \endif \if EN Gets or sets a value indicating whether every FrameworkElement Loaded event should try ViewModel auto-wiring. \endif

FallbackWindowHeight Property

\if KO Fallback Window Height 값을 가져오거나 설정합니다. \endif \if EN Gets or sets the fallback window height used when displaying a UserControl or Page without a region navigator. Defaults to 600. \endif

FallbackWindowWidth Property

\if KO Fallback Window Width 값을 가져오거나 설정합니다. \endif \if EN Gets or sets the fallback window width used when displaying a UserControl or Page without a region navigator. Defaults to 800. \endif

RegisterDefaultServices Property

\if KO Register Default Services 값을 가져오거나 설정합니다. \endif \if EN Gets or sets a value indicating whether Dreamine default WPF services should be registered automatically. \endif

ViewManager

#ctor Method

\if KO 지정한 설정으로 클래스의 새 인스턴스를 초기화합니다. \endif \if EN Initializes a new instance of with an explicit resolver and optional fallback window dimensions for UserControl/Page views. Prefer this constructor in tests and production code to avoid the global DMContainer dependency. \endif

resolver— \if KO resolver에 사용할 값입니다. \endif \if EN The service resolver used to obtain ViewModel instances. \endif
fallbackWindowWidth— \if KO fallback Window Width에 사용할 값입니다. \endif \if EN Width of the fallback window. Defaults to 800. \endif
fallbackWindowHeight— \if KO fallback Window Height에 사용할 값입니다. \endif \if EN Height of the fallback window. Defaults to 600. \endif
#ctor Method

\if KO 지정한 설정으로 클래스의 새 인스턴스를 초기화합니다. \endif \if EN Initializes a new instance of backed by the global DMContainer. \endif

ActivateExistingWindow Method

\if KO Activate Existing Window 작업을 수행합니다. \endif \if EN Performs the activate existing window operation. \endif

windowKey— \if KO window Key에 사용할 값입니다. \endif \if EN The value used for window key. \endif
DisplayResolvedView Method

\if KO Display Resolved View 작업을 수행합니다. \endif \if EN Performs the display resolved view operation. \endif

view— \if KO view에 사용할 값입니다. \endif \if EN The value used for view. \endif
viewModel— \if KO view Model에 사용할 값입니다. \endif \if EN The value used for view model. \endif
viewModelType— \if KO view Model Type에 사용할 값입니다. \endif \if EN The value used for view model type. \endif
useRegionNavigator— \if KO use Region Navigator에 사용할 값입니다. \endif \if EN The value used for use region navigator. \endif
GetViewKey Method

\if KO View Key 값을 가져옵니다. \endif \if EN Gets the view key value. \endif

type— \if KO type에 사용할 값입니다. \endif \if EN The value used for type. \endif

반환: \if KO Get View Key 작업에서 생성한 결과입니다. \endif \if EN The result produced by the get view key operation. \endif

Navigate Method

\if KO Navigate 작업을 수행합니다. \endif \if EN Performs the navigate operation. \endif

viewModel— \if KO view Model에 사용할 값입니다. \endif \if EN The value used for view model. \endif
RegisterDisplayStrategy Method

\if KO Register Display Strategy 작업을 수행합니다. \endif \if EN Registers a custom display strategy that handles view types not natively supported (Window, UserControl, Page). Strategies are evaluated in registration order before the built-in switch, so registered strategies take precedence. \endif

strategy— \if KO strategy에 사용할 값입니다. \endif \if EN The strategy to register. \endif
Show Method

\if KO Show 작업을 수행합니다. \endif \if EN Performs the show operation. \endif

viewModelType— \if KO view Model Type에 사용할 값입니다. \endif \if EN The value used for view model type. \endif
Show``1 Method

\if KO Show 작업을 수행합니다. \endif \if EN Performs the show operation. \endif

ShowPage Method

\if KO Show Page 작업을 수행합니다. \endif \if EN Performs the show page operation. \endif

page— \if KO page에 사용할 값입니다. \endif \if EN The value used for page. \endif
viewModel— \if KO view Model에 사용할 값입니다. \endif \if EN The value used for view model. \endif
useRegionNavigator— \if KO use Region Navigator에 사용할 값입니다. \endif \if EN The value used for use region navigator. \endif
ShowUserControl Method

\if KO Show User Control 작업을 수행합니다. \endif \if EN Performs the show user control operation. \endif

userControl— \if KO user Control에 사용할 값입니다. \endif \if EN The value used for user control. \endif
viewModel— \if KO view Model에 사용할 값입니다. \endif \if EN The value used for view model. \endif
useRegionNavigator— \if KO use Region Navigator에 사용할 값입니다. \endif \if EN The value used for use region navigator. \endif
ShowWindow Method

\if KO Show Window 작업을 수행합니다. \endif \if EN Performs the show window operation. \endif

window— \if KO window에 사용할 값입니다. \endif \if EN The value used for window. \endif
viewModel— \if KO view Model에 사용할 값입니다. \endif \if EN The value used for view model. \endif
viewModelType— \if KO view Model Type에 사용할 값입니다. \endif \if EN The value used for view model type. \endif
TryResolve``1 Method

\if KO Resolve 작업을 시도하고 성공 여부를 반환합니다. \endif \if EN Attempts to resolve and returns whether the operation succeeds. \endif

반환: \if KO Try Resolve 작업에서 생성한 결과입니다. \endif \if EN The result produced by the try resolve operation. \endif

_customStrategies Field

\if KO custom Strategies 값을 보관합니다. \endif \if EN Stores the custom strategies value. \endif

_fallbackWindowHeight Field

\if KO fallback Window Height 값을 보관합니다. \endif \if EN Stores the fallback window height value. \endif

_fallbackWindowWidth Field

\if KO fallback Window Width 값을 보관합니다. \endif \if EN Stores the fallback window width value. \endif

_resolver Field

\if KO resolver 값을 보관합니다. \endif \if EN Stores the resolver value. \endif

WindowStateService

IsOpen Method

\if KO Is Open 조건을 확인합니다. \endif \if EN Determines whether is open. \endif

windowKey— \if KO window Key에 사용할 값입니다. \endif \if EN The value used for window key. \endif

반환: \if KO Is Open 조건이 충족되면 이고, 그렇지 않으면 입니다. \endif \if EN when the is open condition is satisfied; otherwise, . \endif

MarkClosed Method

\if KO Mark Closed 작업을 수행합니다. \endif \if EN Performs the mark closed operation. \endif

windowKey— \if KO window Key에 사용할 값입니다. \endif \if EN The value used for window key. \endif
MarkOpened Method

\if KO Mark Opened 작업을 수행합니다. \endif \if EN Performs the mark opened operation. \endif

windowKey— \if KO window Key에 사용할 값입니다. \endif \if EN The value used for window key. \endif
SetState Method

\if KO State 값을 설정합니다. \endif \if EN Sets the state value. \endif

windowKey— \if KO window Key에 사용할 값입니다. \endif \if EN The value used for window key. \endif
isOpen— \if KO is Open에 사용할 값입니다. \endif \if EN The value used for is open. \endif
ValidateWindowKey Method

\if KO Window Key 값의 유효성을 검사합니다. \endif \if EN Validates the window key value. \endif

windowKey— \if KO window Key에 사용할 값입니다. \endif \if EN The value used for window key. \endif
_states Field

\if KO states 값을 보관합니다. \endif \if EN Stores the states value. \endif

StateChanged Event

\if KO State Changed 상황이 발생할 때 알립니다. \endif \if EN Occurs when state changed takes place. \endif

WpfDialogService

Confirm Method

\if KO Confirm 작업을 수행합니다. \endif \if EN Performs the confirm operation. \endif

message— \if KO 처리할 메시지입니다. \endif \if EN The message to process. \endif
title— \if KO title에 사용할 값입니다. \endif \if EN The value used for title. \endif

반환: \if KO Confirm 조건이 충족되면 이고, 그렇지 않으면 입니다. \endif \if EN when the confirm condition is satisfied; otherwise, . \endif

ConfirmAsync Method

\if KO Confirm Async 작업을 수행합니다. \endif \if EN Performs the confirm async operation. \endif

message— \if KO 처리할 메시지입니다. \endif \if EN The message to process. \endif
title— \if KO title에 사용할 값입니다. \endif \if EN The value used for title. \endif

반환: \if KO Confirm Async 작업에서 생성한 Task<bool> 결과입니다. \endif \if EN The Task<bool> result produced by the confirm async operation. \endif

ShowError Method

\if KO Show Error 작업을 수행합니다. \endif \if EN Performs the show error operation. \endif

message— \if KO 처리할 메시지입니다. \endif \if EN The message to process. \endif
title— \if KO title에 사용할 값입니다. \endif \if EN The value used for title. \endif
ShowMessage Method

\if KO Show Message 작업을 수행합니다. \endif \if EN Performs the show message operation. \endif

message— \if KO 처리할 메시지입니다. \endif \if EN The message to process. \endif
title— \if KO title에 사용할 값입니다. \endif \if EN The value used for title. \endif
ShowMessageAsync Method

\if KO Show Message Async 작업을 수행합니다. \endif \if EN Performs the show message async operation. \endif

message— \if KO 처리할 메시지입니다. \endif \if EN The message to process. \endif
title— \if KO title에 사용할 값입니다. \endif \if EN The value used for title. \endif

반환: \if KO Show Message Async 작업에서 생성한 결과입니다. \endif \if EN The result produced by the show message async operation. \endif