Влад Макух
Влад Макух

Reputation: 311

How to bind a UWP project image from another project?

I have image control in UWP page. I wrote path to sourse that is located in other project, but image don't show nor designer nor runtime. How to fix this problem?

<Page
x:Class="Platform.Universal.LoadingWindow.LoadingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="Transparent">
<Grid>
    <Image x:Name="LoadingImage"
        Stretch="Fill" 
           Source="ms-appdata:///Resources.Universal/Resources/ChangableFiles/Default/LoadingImage.png" />
</Grid>

Upvotes: 1

Views: 51

Answers (2)

Konrad Śledziewski
Konrad Śledziewski

Reputation: 120

Use ms-appx: instead of ms-appdata: and make sure you have access to directory where the image is stored.

You can use Assets directory to store the images and easily use it in the code.

For e.g: Source="ms-appx:///Assets/LoadingImage.png" />

Upvotes: 0

Ivan I
Ivan I

Reputation: 9990

You can't. The only way you could possibly do it if you had set the broadFileSystemAccess in the manifest, then loaded the image from the file system path in the code behind and assigned it (or something similar from the view model).

But just to note that on Microsoft Store it is almost certain that your app will be denied to use broadFileSystemAccess if this is the reason to ask for it.

Upvotes: 3

Related Questions