MvvmCross / MvvmCross-AndroidSupport

Android support library packages for MvvmCross: The .NET MVVM framework for cross-platform solutions.
http://mvvmcross.com
15 stars 0 forks source link

Binding to vector drawable doesn't seem to work #306

Closed benson82 closed 7 years ago

benson82 commented 7 years ago

To help us fix your issue, please provide the information in the below template.

Note: There is often little we can do without a minimal reproducible sample of the issue, so please provide that in a standalone git repository and link it here.

Please only file bugs verified on latest version of MvvmCross and stable Xamarin tools

Steps to reproduce

  1. using mvvmcross.droid.support.v7.appcompat.widget.MvxAppCompatImageView in my layout.xml
  2. bind my vector drawable icon to DrawableId

    Expected behavior

The drawable should show

Actual behavior

Nothing shows. How do i bind to vector drawables (app:srcCompat) instead of "normal" .png (android:src)

Configuration

Version: 4.x

fedemkr commented 7 years ago

Hi, that feature was added in version 4.3, if you have that version then you can bind it using "ResourceName", if not you have to create a custom target binding to do that, you can see the current implementation to do that:

https://github.com/MvvmCross/MvvmCross/blob/develop/MvvmCross/Binding/Droid/Target/MvxImageViewResourceNameTargetBinding.cs

kjeremy commented 7 years ago

And of course don't forget AppCompatDelegate.CompatVectorFromResourcesEnabled = true;

kjeremy commented 7 years ago

@benson82 does this work? can we close this?

benson82 commented 7 years ago

Yes I prefer to bind to ResourceId, instead of ResourceName, because of compile time resource checking. With a custom target binding it worked fine. Thanks a lot. It worked without setting the CompatVectorFromResourcesEnabled prop. Where do you usually set this?