用于 Win8.1 向后兼容的 UWP 应用程序项目结构

UWP app project structure for Win8.1 backward compatibility

我正在编写一个新的 UWP 应用程序,我想尽可能多地重用业务逻辑代码(在 ViewModel 层中)来创建一个单独的 WPF 应用程序,它将 运行 Windows 7/8/8.1

我正在使用 MVVM Light 工具包来帮助解决这个问题

我当前的解决方案结构有 4 个项目:一个模型、一个 ViewModel、一个 UWP 应用程序和一个 WPF 应用程序,但我正在努力设置 ViewModel,使其能够同时针对 7/8 /8.1 和 10.

查看 Oren Novotny's blog 我的想法是设置 ViewModel 以 net45 和 netcore45 框架(以及 UAP 框架)为目标,这将涵盖 Windows 8/8.1 Store Apps 和 . NET 4.5 桌面应用程序,但我不确定这会使代码本身变得多么复杂,因为这是我第一次经历这个。

  1. 有没有人看过关于这类问题的好文章?我找到的所有文章都在谈论将应用程序从 8.1 升级到 10,但没有编写应用程序以在支持两个平台时最大限度地减少编码工作

  2. 我想我将需要 2 个不同的视图:一个空白通用 Windows 应用程序和一个经典 WPF 应用程序,但我是否还需要有 2 个单独的 ViewModel 项目:经典桌面dll(适用于 <= Win 8.1)和通用 Windows Class 库?或者我可以使用 Oren Novotny 的 post 建议的框架目标构建单个 dll 吗?

任何帮助或指点将不胜感激。

谢谢

I am writing a new UWP app, which I would like to reuse as much of the business logic code (in the ViewModel layer) as I can to create a separate WPF app which will run on Windows 7/8/8.1

在这种情况下,您只需要在 Visual Studio 2015 年创建一个面向 .NET 4.6 和 UWP 的可移植 class 库。

Looking at Oren Novotny's blog my thinking was to set-up the ViewModel to target the net45 and netcore45 frameworks (alongside the UAP framework) which would cover both Windows 8/8.1 Store Apps and .NET 4.5 Desktop apps

目前,我们无法创建同时涵盖 UWP 和 Windows8/8.1 Store App 的可移植库。作为替代方法,我建议您使用共享项目,它可以被 Windows Store App 8/8.1、WPF net45/net46 和 UWP 项目引用。