-
[DX_WPF] 시작하기 (MDI)DevExpress/DX_WPF 2024. 1. 10. 07:47
New Solution Project
이후에 TargetFramework 8.0 으로 바꾸면 실행이 안됨.Common 프로젝트에 DXDynamicModule 패키지 추가.
DXDynamicModule.2.2.4.nupkg0.01MB파일 수정 (Module 동적로드)
App.xaml0.00MBBootstrapper.cs0.00MBApp.xaml.cs
using DevExpress.Mvvm; using DevExpress.Mvvm.ModuleInjection; using DevExpress.Mvvm.UI; using DevExpress.Xpf.Core; using SentryReport.Common; using SentryReport.Main.Properties; using SentryReport.Main.ViewModels; using SentryReport.Main.Views; using System.ComponentModel; using System.Windows; using AppModules = SentryReport.Common.Modules; namespace SentryReport.Main; public partial class App : Application { public App() { ApplicationThemeHelper.UpdateApplicationThemeName(); SplashScreenManager.CreateThemed().ShowOnStartup(); } protected override void OnExit(ExitEventArgs e) { ApplicationThemeHelper.SaveApplicationThemeName(); base.OnExit(e); } void OnApplicationStartup(object sender, StartupEventArgs e) { Bootstrapper.Run(); } }
Bootstrapper.cs
using DevExpress.Mvvm.ModuleInjection; using DevExpress.Mvvm.UI; using DevExpress.Mvvm; using DevExpress.Xpf.Core.MvvmSample; using SentryReport.Common; using SentryReport.Main.ViewModels; using SentryReport.Main.Views; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Reflection; using DXDynamicModule.Interfaces; using DXDynamicModule; using DevExpress.Xpf.Bars; using DevExpress.Xpf.WindowsUI; using DryIoc; using System.Windows.Threading; using DevExpress.Drawing.Internal.Fonts; namespace SentryReport.Main; public class Bootstrapper { const string StateVersion = "1.0"; public static Bootstrapper Default { get; protected set; } private ICustomContainer DryContainer { get; set; } = DevDynamicModule.DryContainer; public IModuleManager Manager { get { return ModuleManager.DefaultManager; } } public static void Run() { Default = new Bootstrapper(); Default.RunCore(); } protected Bootstrapper() { } public virtual void RunCore() { // Dynamic load modules. ContainerBootstrap(DryContainer as IContainerRegistry); DevDynamicModule.CreateDevModuleCatalog(); RegisterModules(DryContainer as IContainerProvider); //if (!RestoreState()) InjectOrNavigateModules(); ConfigureNavigation(); ShowMainWindow(); } private void ContainerBootstrap(IContainerRegistry containerRegistry) { } protected virtual void RegisterModules(IContainerProvider containerProvider) { //Manager.Register(Regions.MainWindow, new Module(Modules.FrameView, () => containerProvider.Resolve<FrameViewModel>(), typeof(FrameView))); } protected virtual bool RestoreState() { #if !DEBUG if (Settings.Default.StateVersion != StateVersion) return false; return Manager.Restore(Settings.Default.LogicalState, Settings.Default.VisualState); #else return false; #endif } protected virtual void InjectOrNavigateModules() { //Manager.InjectOrNavigate(Regions.MainWindow, Modules.FrameView); } protected virtual void ConfigureNavigation() { } protected virtual void ShowMainWindow() { App.Current.MainWindow = new MainWindow(); App.Current.MainWindow.Show(); } }
New Project Module
<ImplicitUsings>enable</ImplicitUsings> 삭제
XXXXXModule.cs
using DXDynamicModule.Interfaces; namespace SentryReport.Report; public class ReportModule : IDynamicModule { public void OnInitialized(IContainerProvider containerProvider) { throw new System.NotImplementedException(); } public void RegisterTypes(IContainerRegistry containerRegistry) { throw new System.NotImplementedException(); } }
DevExpress.Wpf Nuget 추가
View 추가
ViewModel 추가
Views
<UserControl x:Class="DXModular.ModuleA.Views.ModuleAView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:views="clr-namespace:DXModular.ModuleA.Views" xmlns:viewModels="clr-namespace:DXModular.ModuleA.ViewModels" xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{dxmvvm:ViewModelSource viewModels:ModuleAViewModel}"> <Grid> </Grid> </UserControl>
ViewModels
internal => public
https://github.com/dlsenfl3/DXApplication1
ViewModel with Constructor Injection in Xaml
POCO ViewModel with Constructor Injection in Xaml
You have yet to view any tickets. Your search criteria do not match any tickets. A server error occurred while processing your request. Please try again at a later time.
supportcenter.devexpress.com
728x90'DevExpress > DX_WPF' 카테고리의 다른 글
[DX_WPF] ISupportServices (0) 2024.01.19 [DX_WPF] DevExpress 다국어 지원 (0) 2024.01.12 [DX_WPF] DockLayoutManager SaveLayout (0) 2023.12.14 [DX_WPF] DevExpress Create a Custom Service (0) 2023.11.29 [DX_WPF] xpf ~ Reference (1) 2023.11.28 댓글