Struggling to bind local images in an MvxImageView with MvvmCross

前端 未结 3 540
终归单人心
终归单人心 2021-01-19 13:46

I can\'t seem to get images to bind properly in an MvxListView

Here is the template:




        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-19 14:22

    I have used this to make it work for me:

    public class StringToIntValueConverter : MvxValueConverter
                {
                    protected override int Convert(string value, Type targetType, object parameter, CultureInfo culture)
                    {
                        int image = 0;
                        if(value == "song")
                            image = Resource.Drawable.icon_category_song;
    
                        return image;
                    }
                }
    

    To use this in the Android layout:

    
    

    In this example "Type" is a string containing the word "song".

提交回复
热议问题