Xamarin表单:如何在PCL项目中使用嵌入式资源进行图像处理

Ely*_*ykx 5 image mvvm imagesource xamarin xamarin-forms

我的资源目录中有4个图像到我的便携式项目中,我想直接将它们用于ImageSource(因为我需要绑定它).

ImageSource myImageSource = ImageSource.FromResource("resources.image.png");
Run Code Online (Sandbox Code Playgroud)

我试过这个,但它不认识路径.如何将我的图像用于ImageSource?

Ely*_*ykx 3

好吧,我的错是我忘记了 Resources 目录之前的项目名称

ImageSource myImageSource = ImageSource.FromResource("NameOfProject.Resources.image.png");
Run Code Online (Sandbox Code Playgroud)