Maui使用WindowsDesktop库

Maui使用WindowsDesktop库

WindowsDesktop库通过在项目文件PropertyGroup节点中设置<UseWindowsForms>true</UseWindowsForms>  <UseWPF>true</UseWPF>实现,在TargetFrameworks中增加net8.0-windows,并且在PropertyGroup节点上添加判断条件。
由于未知原因无法直接在Maui项目中进行设置,需要在单独的类库中设置后再由Maui项目进行引用。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net8.0;net8.0-windows</TargetFrameworks>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
    <UseWindowsForms>true</UseWindowsForms>
    <UseWPF>true</UseWPF>
    <!--MSAL will run on Windows 7 and 8 but requires to be built against Win10 to use WinRT APIs for WAM
    See https://learn.microsoft.com/dotnet/standard/analyzers/platform-compat-analyzer and
    https://github.com/dotnet/designs/blob/main/accepted/2020/platform-checks/platform-checks.md for details-->
    
    <SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
  </PropertyGroup>
</Project>
Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy