Search code examples
android.netuwpuno-platform

Setting Bitmaps from ViewModels in Uno.Platform won't work for Android


I'm playing with Uno.Platform and my ViewModel has this kind of code:

new Item
{
    Name = "Mario",
    Number = 11,
    Image = new Uri("ms-appx:///mario.png", UriKind.Absolute)
},

Then, in XAML I have an <Image Source="{Binding Image}" />

Problem? it only works for UWP and Web heads

If I want to make it work in Android I have to place the bitmaps inside the Resources\drawables as AndroidResource and change the Uri to => new Uri("mario.png"), but that breaks UWP and Web.

Is there a good way to overcome this limitation?


UPDATE

As @JeromeLaban suggested I updated Uno.UI to the latest version (pre-release) and it started working! I'm using ms-appx:/// absolute uris all the way. Sadly this broke the Web head Image using Bindings.

A workaround is to edit the linker file: Into the WASM project, go to the LinkerConfig.xml and add this inside the node

<assembly fullname="System">
    <type fullname="System.*Converter" />
</assembly>

Solution

  • As @JeromeLaban suggested I updated Uno.UI to the latest version (pre-release) and it started working! I'm using ms-appx:/// absolute uris all the way. Sadly this broke the Web head Image using Bindings. A workaround is to edit the linker file: Into the WASM project, go to the LinkerConfig.xml and add this inside the node

    <assembly fullname="System">
        <type fullname="System.*Converter" />
    </assembly>