admin管理员组文章数量:1435859
I am working on a WinUI3 project, in the dependencies my frameworks are stated as Microsoft.NETCore.App
and Microsoft.Windows.SDK.Net.Ref
. I need a class to represent a rectangular geometry. I have found an already defined class: .windows.rect?view=windowsdesktop-9.0
It seems this class is within WindowsBase
assembly that I have within my project under `Microsoft.NETCore.App framework, but I don't know how to reference it ,namespaces
Online it is listed under Windows Desktop 9 (which means Windows Presentation Foundation?), anyway I cannot reference this class from within my project.
Can however reference Windows.Foundation.Rect
.foundation.rect?view=winrt-26100
but it misses much of the functionality I need such as IntersectsWith(Rect)
, Offset
, etc...
Also can reference System.Drawing.Rectangle
.drawing.rectangle?view=net-8.0 which is listed under .NET but in the description says is designed for Windows Forms which I heard is to be discontinued
So first, I don't understand why I can access one but not the other, also what should I do? To be honest I spent so much time trying to make sense of it all that perhaps it would be better to implement everything with my own code.
I am working on a WinUI3 project, in the dependencies my frameworks are stated as Microsoft.NETCore.App
and Microsoft.Windows.SDK.Net.Ref
. I need a class to represent a rectangular geometry. I have found an already defined class: https://learn.microsoft/en-us/dotnet/api/system.windows.rect?view=windowsdesktop-9.0
It seems this class is within WindowsBase
assembly that I have within my project under `Microsoft.NETCore.App framework, but I don't know how to reference it https://referencesource.microsoft/#WindowsBase,namespaces
Online it is listed under Windows Desktop 9 (which means Windows Presentation Foundation?), anyway I cannot reference this class from within my project.
Can however reference Windows.Foundation.Rect
https://learn.microsoft/en-us/uwp/api/windows.foundation.rect?view=winrt-26100
but it misses much of the functionality I need such as IntersectsWith(Rect)
, Offset
, etc...
Also can reference System.Drawing.Rectangle
https://learn.microsoft/en-us/dotnet/api/system.drawing.rectangle?view=net-8.0 which is listed under .NET but in the description says is designed for Windows Forms which I heard is to be discontinued
So first, I don't understand why I can access one but not the other, also what should I do? To be honest I spent so much time trying to make sense of it all that perhaps it would be better to implement everything with my own code.
Share Improve this question edited Nov 15, 2024 at 19:23 Eliy Arlev asked Nov 15, 2024 at 19:09 Eliy ArlevEliy Arlev 5782 gold badges4 silver badges16 bronze badges 7 | Show 2 more comments1 Answer
Reset to default 0as Simon Mourier Commented the solution was to add <UseWPF>true</UseWPF>
to .csproj
project file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<UseWPF>true</UseWPF>
However it breaks the project as WinUI auto generated code didn't work propertly.
Was related to How can I reference WindowsBase in .Net5?
本文标签: winui 3telling apart Rect class in different assemblies of c eco systemStack Overflow
版权声明:本文标题:winui 3 - telling apart Rect class in different assemblies of c# eco system - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745675437a2669824.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
<TargetFramework>net8.0-windows</TargetFramework>
for example and<UseWPF>true<UseWPF>
in it, reference that project from your WinUI3 project and you will be able to useSystem.Windows.Rect
fromWindowsBase
. I never mentioned Windows.Foundation.Rect. – Simon Mourier Commented Nov 16, 2024 at 5:17