在 Xamarin.Forms 中使用 System.Windows.Forms [英] using System.Windows.Forms in Xamarin.Forms

查看:32
本文介绍了在 Xamarin.Forms 中使用 System.Windows.Forms的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Xamarin.Forms 中使用 System.Windows.Forms 类?!我有一个 windows 应用程序,我想在我的 Xamarin.Forms 应用程序中使用它的类,包括使用 windows.forms 的类.例如,我有一个使用 TreeNode 的类,我在 xamarin 中找不到合适的等效类,所以我想知道是否有可能在 xamarin 项目中使用 windows.forms,因为现在它无法识别 windows.forms 命名空间,它只是让我使用 windows.forms.Input

Is it possible to use System.Windows.Forms classes in Xamarin.Forms?! I have a windows application and I want to use its classes in my Xamarin.Forms app, including the classes that have used windows.forms. For example I have a class that's used TreeNode, I can't find a suitable equivalent class in xamarin so I was wondering if there's a possibility of using windows.forms in xamarin projects because right now it doesn't recognize windows.forms namespace, it just lets me use windows.forms.Input

提前致谢

推荐答案

不,这行不通,而且很可能(并且希望)永远不可能.我也认为这不是你应该想要的.

No, that is not going to work and most likely (and hopefully) will never be possible. I also think that is not something that you should want.

WinForms 和 Xamarin.Forms 都做同样的事情:为您的应用程序提供 UI.但是您希望为您的移动应用程序提供的 UI 应该与桌面上的 UI 有很大不同.我们已经尝试将桌面应用程序放在带有 Windows CE 的移动设备上,以后不要再这样做了.

Both WinForms and Xamarin.Forms do kind of the same thing: provide a UI for your application. But the UI you want to have for your mobile app should be a lot different than one on the desktop. We've tried putting desktop applications on mobile with Windows CE, let's never ever do that again.

移动范式有很多非常具体的 UI 元素和概念,它们只能在移动设备上使用.移植当前的应用程序应该会让您重新思考这一点.

The mobile paradigm has a lot of very specific UI elements and concepts that only work on a mobile device. Porting a current application should make you rethink that.

对于您的问题:我无法准确说明您要做什么,但您似乎正在尝试使用 Xamarin 将现有应用移植到移动设备,太棒了!尝试重用尽可能多的代码,但要从业务逻辑中重用.不是你的用户界面.具体来说,您要求的是 TreeNode,我认为这些在移动设备上不可用是有原因的,您可能希望在最高级别显示一个列表,每当有人选择一个选项时,您就导航到下一页并向下钻取进入您的数据.

For your question: I can't make up what you're trying to do exactly, but it seems that you are trying to port an existing app to mobile with Xamarin, great! Try to reuse as much code as possible, but from the business logic. Not your UI. Specifically you are asking for a TreeNode, I think there is a reason that these aren't available on mobile, you probably want to show a list on the highest level and whenever someone selects an option, you navigate to the next page and drill down into your data.

虽然这不是您问题的答案,但我希望它可以帮助您了解您可能想要重新考虑您的处理方法.

Although this is not a answer to your question, I hope it helps you understand that you might want to rethink your approach on things.

对于一些更高级的 Xamarin.Forms 控件,您可以转到 GitHub 并在那里搜索、构建您自己的控件,或者查看第三方供应商,如 Telerik、DevExpress 或 Syncfusion.

For some more advanced Xamarin.Forms controls you can either turn to GitHub and search through there, build your own, or have a look at third-party vendors like Telerik, DevExpress or Syncfusion.

这篇关于在 Xamarin.Forms 中使用 System.Windows.Forms的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆