【问题标题】:How to migrate Xamarin.Forms shared project in to .NetStandard project如何将 Xamarin.Forms 共享项目迁移到 .NetStandard 项目
【发布时间】:2019-07-16 12:03:52
【问题描述】:

我有一个 Xamarin.Forms 共享项目(不是 PCL)应用程序并希望迁移到 .NetStandard 项目。我在网上查过,但没有得到任何参考。我欢迎你的提示

谢谢,

【问题讨论】:

  • 我建议创建一个新的空白 netStandard 项目,然后将所有文件一个一个复制粘贴

标签: xamarin xamarin.forms


【解决方案1】:
  1. 在与旧项目相同的文件夹中创建一个新的 .NET Standard 项目 共享项目,而不仅仅是使用将所有文件添加到新项目 从 Visual Studio 中的 SolutionExplorer 拖放。
  2. 添加需要的包
  3. 替换您的平台特定代码

喜欢

 #if __MOBILE__
// Xamarin iOS or Android-specific code
#endif

//OR

#if __IOS__
// iOS-specific code
#endif 

if(Device.Idiom == TargetIdiom.Phone)//TargetIdiom.Tablet OR what ever you want
{
 -----
}
if(Device.RuntimePlatform == Device.iOS)//OR Device.Android
{
 -----
}

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2014-01-18
  • 1970-01-01
  • 2018-02-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多