【发布时间】:2016-05-11 01:55:42
【问题描述】:
我有一个名称为 fb.png 的图像,它位于根项目 (prtable) 中,我将此图像添加到 Droid 项目中的 Resource>drawble。
Thees 是我的MainPage.xaml 代码:
<Image x:Name="img1"></Image>
Thees 是我的MainPage.xaml.cs 代码:
public MainPage()
{
InitializeComponent();
ImageSource img = ImageSource.FromResource("App2.fb.png");
img1.Source = img;
img1.Aspect = Aspect.AspectFit;
img1.BackgroundColor = Color.Navy;
}
需要出现什么变化?
【问题讨论】:
-
您说您的图像被称为 fb.png,但在您的代码中您将其称为“App2.fb.png”。您需要在 ImageSource.FromResource 中使用“fb.png”
标签: xaml xamarin xamarin.forms