microsoft / Win2D

Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration. It is available to C#, C++ and VB developers writing apps for the Windows Universal Platform (UWP). It utilizes the power of Direct2D, and integrates seamlessly with XAML and CoreWindow.
http://microsoft.github.io/Win2D
Other
1.78k stars 285 forks source link

Cannot add Win2D to WinUI3 project #883

Open BubbaRichard opened 1 year ago

BubbaRichard commented 1 year ago

I had been 'investigating' Win2D in UWP for over a year and I decided to try it with Win2D. I create a Project Reunion project and Add the Microsoft.Graphics.Win2D nuget package. I get the build error "WMC101 A Project cannot have more than one ApplicationXaml item." Researched it, the error has no information from the MSDN. I tried the fix for XamarinUWP listed here https://github.com/xamarin/Xamarin.Forms/issues/6335 but there is absolutely no changes in WinUI3.

Any suggestions, Thanks, Bubba

getrou commented 1 year ago

Hello! Could you give us some more information on your new project setup?

Type of app (e.g. C# packaged app, C++ WinRT component, etc) Win2D version (I assume 1.0.3.1) WinAppSDK version WinAppSDK VSIX template version (from the Manage Extensions menu in VS) VS version

BubbaRichard commented 1 year ago

Defaults for Visual Studio 2019 that is up to date. On the last try I followed the guide on the win2d documentation page. c#, Project Reunion, which creates a Windows Desktop application Project Reunion's version in the Manage Extensions window is 0.8.12.81472693 released 8/31/2022 Win2D 1.0.3.1 WinAppSDK and WindowsAppSDK do not appear in the Manage Extension windows but under NuGet the version of WindowsAppSDK is 1.1.4

Regards, Bubba

dr-eck commented 6 months ago

Over a year later, Win2D works in WinUI 3. I created a desktop (not Xamarin) app using VS 2022 17.9 Preview 2, WinAppSDK 1.4 and C++/WinRT. The only changes I had to make were to change "MainPage" to "MainWindow" in the source code and "canvas" to "win2dcanvas" in the XAML.