将WPF应用程序传输到移动c# [英] Transferring an WPF Application to Mobile c#

查看:77
本文介绍了将WPF应用程序传输到移动c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道最简单的方法,可以将我的应用程序转换为可以在Android手机上使用的移动友好版本.任何帮助和指示,将不胜感激.

I'm just wondering the easiest way to transfer my application into a mobile friendly version that I would be able to put onto android phones. Any help and pointers would be appreciated.

推荐答案

Xamarin-这是最好的方法.将代码保存在C#中,可重复使用大量代码.

Xamarin - it's the best way. Keeps your code in C# with loads of code re-use.

假设您使用MVVM设计模式开发了WPF应用程序,然后将其移植到Android上可能并不难.您只需要确保所有非UI代码都是可移植的(因为它使用了可移植类库可用的.Net框架的子集),并移动了特定于Android库的任何设备.如果您一直在使用依赖项注入/IoC,那么这应该相对简单.

Assuming you developed your WPF app using the MVVM design pattern then porting it to Android might not be that hard. You just need to ensure all your non-UI code is portable (as in it uses the subset of the .Net framework that is available to a portable class library) and move anything device specific to an Android library. If you have been using dependency injection/IoC then this should be relatively simple.

Xamarin的另一个选项是Xamarin.Forms.像WPF一样,您可以在Xaml中定义UI,并且可以从大型控件供应商(如DevExpress)中获得控件.Xamarin.Forms的输出是一个跨平台应用程序,因此将根据需要使用的平台特定功能在Android,iOS和UWP上运行-并且有很多插件可以帮助您完成所有这些工作.

The other option with Xamarin is Xamarin.Forms. Like WPF you define your UI in Xaml and there are controls available from the big control vendors like DevExpress. The output of Xamarin.Forms is a cross platform app so will run on Android, iOS and UWP depending on what platform specific features you need to use - and there are plenty of plug-ins to help with all this.

一旦在可移植类库中拥有核心业务逻辑(MVVM的VM和M),则只需要在Android上编写UI层,从那里添加iOS或UWP UI并不太难层.

Once you have the core business logic (the VM and M of MVVM) in a portable class library then you just need to write the UI layer on Android, and from there it's not too hard to add a, iOS or UWP UI layer as well.

此外,如果您使用的是MVVM,您是如何实现的?如果您使用的是PRISM,MVVMCross或MVVMLight,则它们支持Xamarin应用.

Also if you are using MVVM how have you implemented it? If you are using PRISM, MVVMCross or MVVMLight then these support Xamarin apps.

Xamarin博客上有一篇很好的博客文章,展示了如何做类似的事情: https://devblogs.microsoft.com/xamarin/porting-existing-net-apps-to-android/

A good blog post showing how to do something similar is on the Xamarin Blog here: https://devblogs.microsoft.com/xamarin/porting-existing-net-apps-to-android/

这篇关于将WPF应用程序传输到移动c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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