如何将 Xamarin.Forms 共享项目迁移到 .NetStandard 项目

Bha*_*thi 4 xamarin xamarin.forms

我有一个 Xamarin.Forms 共享项目(不是 PCL)应用程序,想要迁移到 .NetStandard 项目。我在网上办理了登机手续,但没有得到任何参考。我欢迎你的提示

谢谢,

Aks*_* M. 5

  1. 在与旧共享项目相同的文件夹中创建一个新的 .NET Standard 项目,然后使用 Visual Studio 中的 SolutionExplorer 中的拖放操作将所有文件添加到新项目中。
  2. 添加需要的包
  3. 替换您的平台特定代码

喜欢

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

//OR

#if __IOS__
// iOS-specific code
#endif 
Run Code Online (Sandbox Code Playgroud)

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