Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to load images from local path in Xamarin.Forms

$
0
0

In my app I download images using dependency service into platform tmp app (in ios, going to implement android version latter), then I load try to show the downloaded images but the If i Bind the image path to a Image control in xaml it never shows the image. By the way im storing a partial path to the image and at runtime i get the full path, the flow is like this:

  1. Download image with dependency service using NSUrlSession.
  2. Move the image to /Caches/ directory in my app root.
  3. Save that partial path like "/Caches/img1.jpg" in a db
  4. Load a view at my app and get the image from the db.
  5. Build the full image path like "file:///Users/mbuild/Library/Developer/CoreSimulator/Devices/BF78E8FE-16D2-4F85-9C64-E8DCC98848F6/data/Containers/Data/Application/570C1598-6EBC-40CC-833E-50478E70FD7C/Library/Caches/53d09f9f-531d-4412-87cb-41a26d986e4e-1513113235590-img_0151.jpg" I try with and without "file://" also try it on a device because this is a simulator path.
  6. Use that path like a viewmodel string property like "ImgSrc"
  7. Bind the property to a Image control in several ways like:

<Image Source="{Binding ImgSrc}" /> OR <Image HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Aspect="AspectFit"> <Image.Source> <FileImageSource File="{Binding ImgSrc}" /> </Image.Source> </Image>

I dont know what im doing wrong
Any Ideas?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>