首页 > 解决方案 > 使用 Xamarin 表单在 Xamarin 中共享图像和声音

问题描述

我们目前正在为一个大学项目开发​​一个多平台应用程序,并决定使用 Xamarin。我们的带有 sqlite 的数据库以及业务逻辑和共享资源应该位于 xamarin 形式中,而 View Controller 和 View 位于本机 xamarin.android 和 xamarin.Ios 中。

我们似乎无法在 Android 上的本机 ImageView 中使用 Xamarin.Forms 图像。

浏览 Xamarin 文档 ( https://docs.microsoft.com/de-de/xamarin/xamarin-forms/user-interface/images?tabs=windows ) 中的 EmbeddedImages 部分时,以下 C# 代码似乎没有在我们的项目中工作。

var embeddedImage = new Image { Source = ImageSource.FromResource("WorkingWithImages.beach.jpg", typeof(EmbeddedImages).GetTypeInfo().Assembly) };

我们可以将源设置为 IamgeSource.FromResource("source") 但typoeof(EmbeddeImages)... 不起作用。即使 BuildAction 正确设置为 Embedded 资源。

此外,我们无法真正理解“使用 XAML”部分的重点,即放置 C# 代码以及 XAML 的位置。

这就是为什么我们尝试将 Xamarin.Forms.Image 从逻辑传递到位图的原因: https ://medium.com/@hakimgulamali88/a-helper-for-converting-a-xamarin-forms-imagesource-to -the-respective-native-images-56a5aaf98156

但是当调试应用程序时变黑并且控制台显示多个威胁正在启动和完成。应用程序保持无响应。

有什么建议吗?

我们感谢任何帮助。谢谢你。

标签: androidxamarinxamarin.formsxamarin.android

解决方案


推荐阅读