Underdog.Wpf 1.0.5

dotnet add package Underdog.Wpf --version 1.0.5                
NuGet\Install-Package Underdog.Wpf -Version 1.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Underdog.Wpf" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Underdog.Wpf --version 1.0.5                
#r "nuget: Underdog.Wpf, 1.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Underdog.Wpf as a Cake Addin
#addin nuget:?package=Underdog.Wpf&version=1.0.5

// Install Underdog.Wpf as a Cake Tool
#tool nuget:?package=Underdog.Wpf&version=1.0.5                

Underdog.Wpf

基于Prism的wpf框架

鸣谢

根据这个修改来的

开发信息

  • NET8 + VS2022
  • WPF

支持功能

  • 移植了Prism框架中的模块化、mvvm、region、dialog
  • 支持NET8及以上版本

快速使用

安装包

    dotnet add package Underdog.Core --version 1.0.4
    dotnet add package Underdog.Wpf --version 1.0.5

1.创建Program.cs文件


    public class Program
    {
        public static IHost? AppHost { get; private set; }
        public static IServiceProvider ServiceProvider => AppHost!.Services;

        [System.STAThreadAttribute()]
        public static void Main(string[] args)
        {
            var builder = Host.CreateDefaultBuilder(args)
                // 注册模块
                .ConfigureServices(ModularityExtension.AddModularity)
                .ConfigureServices((hosting,context)=>
                {
                    Assembly currentAssembly = Assembly.GetExecutingAssembly();

                    services.AddSingleton<App>();
                    services.AddScoped<MainWindow>();
                    services.AddScoped<MainWindowViewModel>();
                    services.AddRegion(); // 添加区域
                    services.AddDialog(); // 添加Dialog
                    services.AddMvvm(); // 添加MVVM
                    // 添加视图扫描器,由于region的name需要传完整视图文件所在程序集的完全限定名,提供视图扫描器获取名称
                    services.AddRegionViewScanner(currentAssembly);
                    services.AddViewsAndViewModels(currentAssembly);
                });

            AppHost = builder.Build();

            AppHost.UseRegion<MainWindow>();
            // 注册区域
            // var regionManager = AppHost.Services.GetService<IRegionManager>();
            // regionManager?.RegisterViewWithRegion("ContentRegion", typeof(ViewA));
            // regionManager?.RegisterViewWithRegion("ContentRegion", typeof(ViewB));

            // 启用模块化
            AppHost.UseModularity();

            AppHost.Run();
        }
    }

2.修改.csproj文件,指定启动对象为Program

  <PropertyGroup>
	  <StartupObject>YourNamespace.Program</StartupObject>
  </PropertyGroup>

3.修改App.xaml

删除 StartupUri="MainWindow.xaml" 属性

4.启动程序

MVVM

Dialog

Region

Modularity

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 116 8/12/2024

修复视图扫描器在模块中失效的bug