在 Xamarin.Forms 中找不到类型图像错误 [英] Type image not found error in Xamarin.Forms

查看:24
本文介绍了在 Xamarin.Forms 中找不到类型图像错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单应用程序,并且有一个 ContentPage XAML 表单.

I have a Forms application, and have ContentPage XAML form.

我尝试向此网格添加图像,但是这段代码给了我错误Type image not found.
注意:我已经在 Recources 下添加了这张图片,并在根文件夹中尝试过.

I try to add an image to this Grid but this code gives me the error Type image not found.
Note : I had been added this image under Recources and tried also on the root folder.

我该如何解决这个问题?

How can I fix this?

注2:我已经通过右键单击项目并将图像添加到项目中.

Note2: I had been by right clicked the project and had added image to project.

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="*" />
  </Grid.RowDefinitions>

  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
  </Grid.ColumnDefinitions>
  <Button Text="1" Grid.Row="0" Grid.Column="0" />
  <image Grid.Row="0" Grid.Column="1" source="image2.png"></image>
  <Button Text="3" Grid.Row="0" Grid.Column="2" />
</Grid>

推荐答案

XML(以及 XAML)是区分大小写的,所以让它成为 ;.

XML (and thus XAML) is case-sensitive, so make it <Image> and </Image>.

像这样:

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="*" />
  </Grid.RowDefinitions>

  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="*" />
  </Grid.ColumnDefinitions>
  <Button Text="1" Grid.Row="0" Grid.Column="0" />
  <Image Grid.Row="0" Grid.Column="1" Source="image2.png"></Image>
  <Button Text="3" Grid.Row="0" Grid.Column="2" />
</Grid>

这篇关于在 Xamarin.Forms 中找不到类型图像错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆