0

I am setting the ImageSource of the ImageBrush of the Background to pictures in a slideshow.

Here is my property in the ViewModel

private ImageSource _CurrentPicture;
public ImageSource CurrentPicture { get { return _CurrentPicture; } set { Set(ref _CurrentPicture, value); } }

Here is the XAML

<ImageBrush  Stretch="UniformToFill" ImageSource="{x:Bind ViewModel.CurrentPicture, Mode=OneWay}"/>

When I set the Uri as the ImageSource to a file on one of my local network Servers (TpsNas) it works and displays the picture.

Uri uriAddress = new Uri("file://TpsNas/Photo/Trees.jpg");
CurrentPicture = new BitmapImage(uriAddress);

When I set the Uri to the ImageSource to a localFile on the D: drive it does not work

Uri uriAddress = new Uri("file:D:\\Trees.jpg");
CurrentPicture = new BitmapImage(uriAddress);

What is the difference?

Terrence
  • 313
  • 2
  • 12
  • UWP doesn't directly give access to file stored in local drives that might be the case here,(I am not sure) So usually I use FilePicker to grant permission – Aravind Belagaje Feb 03 '19 at 18:57
  • Aravind, I am using Win IOT, so the filepicker does not show, or I have not gotten it to show. – Terrence Feb 03 '19 at 19:14
  • I guess in IOT you are limited to the sandbox folders try putting file in installation folder. – Aravind Belagaje Feb 03 '19 at 19:30
  • https://learn.microsoft.com/en-us/windows/uwp/files/file-access-permissions this might help – Aravind Belagaje Feb 03 '19 at 19:30
  • Oh, believe me, I have been all over the docs. Thanks for your input. – Terrence Feb 03 '19 at 20:12
  • How is this question different from your other one? https://stackoverflow.com/questions/54496950/cant-display-image-from-removeable-sd-uwp-windows-iot/54499038 The answer is the same: UWP doesn't have a implicit value converted for file paths to ImageSource, so you will have to do it in code (or in a custom IValueConverter). – Stefan Wick MSFT Feb 03 '19 at 21:47
  • After you successfully helped me access photos on the SD card of my device, I am attempting to access the photos on my network storage device. I can access on the NAS from my App while in Dev mode in VS,but when the app gets deployed to the device, I can't. I guess I am having authentication issues. Can't seem to find a way to pass credentials. I guess I need an account on the device that has the same credential as an account on the NAS? Now that I discuss it, my question is not the correct question. – Terrence Feb 05 '19 at 00:24

0 Answers0