how to bind an image src to resource drawable image with Mvvmcross?

后端 未结 4 1188
走了就别回头了
走了就别回头了 2020-12-20 12:38

I\'m trying to bind an image\'s src.

I have tried using MvxHttpImageView like this



        
4条回答
  •  情歌与酒
    2020-12-20 13:14

    For latest MvvmCross next solution is actual:

    In markup:

    
    

    In converter:

    public class TypeToImageStringConverter : MvxValueConverter
    {
        protected override int Convert(VacationType value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            switch (value)
            {
                case VacationType.RegularVacation:
                    return Resource.Drawable.Icon_Request_Green;
                case VacationType.SickLeave:
                    return Resource.Drawable.Icon_Request_Blue;
                case VacationType.LeaveWithoutPay:
                    return Resource.Drawable.Icon_Request_Dark;
                case VacationType.OvertimeVacation:
                    return Resource.Drawable.Icon_Request_Gray;
                case VacationType.ExceptionalLeave:
                    return Resource.Drawable.Icon_Request_Plum;
                default:
                    return Resource.Drawable.Icon_Request_Gray;
            }
        }
    }
    

    All sense is that you just must give out a drawable resource id.

提交回复
热议问题