简体   繁体   中英

Xamarin Forms Dynamic bind image in a ViewCell

I'm in trouble with dynamic bind of images in a ViewCell. I have a shared project for Android and iOS. My ViewCell is so defined

<ViewCell>
    <StackLayout Padding="5" Orientation="Vertical">
        <StackLayout Orientation="Horizontal">
            <Image WidthRequest="32" HeightRequest="32" Source="{Binding Image}"></Image>
     <Label Text="{Binding Source}" FontSize="Medium" TextColor="#003056"></Label>
     </StackLayout>
...

The Image property is so defined in the class

public ImageSource Image {
            get
            {
                ImageSource imageSource = ImageSource.FromResource("MyProject.Images.image001.png");
                return imageSource;
            }

The Images folder is in the shared project. The imageSource returned is not null, there are no errors but the images is not shown. Can you help, plese?

Thanks

确保使用属性菜单(右键单击)将每个映像的“构建”选项设置为“嵌入式资源”,如下所述: https : //developer.xamarin.com/guides/xamarin-forms/user-interface/images/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM