xamarin.forms - Xamarin Forms - Get path of embedded file -


i'm trying hours/days file placed pcl part

enter image description here

i saw examples using baseurl want make cross platform , can't found how implement onto uwp..

so i'm trying local file's url. images, i'm using imagesource.fromresource("gif.example.gif") doesn't work..

i tried gifsource = new uri(imagesource.fromresource("gif.example.gif").tostring()); but.. nothing !

there custom control:

public class gif : webview {     public static readonly bindableproperty gifsourceproperty =         bindableproperty.create(nameof(uri), typeof(string), typeof(gif), null);     public string gifsource     {         { return (string)getvalue(gifsourceproperty); }         set { setvalue(gifsourceproperty, value); }     }      action<string> action;     public void registeraction(action<string> callback)     {         action = callback;     }      public void cleanup()     {         action = null;     }      public void invokeaction(string data)     {         if (action == null || data == null)         {             return;         }         action.invoke(data);     } } 

thank !

to image pcl-project must use full path (with namespace) image.

in case: var src = imagesource.fromresource("gifproject.gif.example.gif");

and sure "build action" of file set "embedded resource".

you can extend reflection, when don't want provide namespace directly.

you can find more infos on how deal embedded images on xamarin developer page.


Comments