[英]How to bind a UWP project image from another project?
I have image control in UWP page. 我在UWP页面中有图像控制 。 I wrote path to sourse that is located in other project, but image don't show nor designer nor runtime.
我写了一个位于其他项目中的sourse路径,但是图像不显示,也没有显示设计器或运行时。 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>
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). 如果您在清单中设置了
broadFileSystemAccess
,然后在后面的代码中从文件系统路径加载图像并分配它(或者从视图模型中类似的东西),那么唯一的方法就可以实现。
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. 但是请注意,在Microsoft Store上几乎可以肯定,如果这是要求它的原因,您的应用程序将被拒绝使用
broadFileSystemAccess
。
Use ms-appx:
instead of ms-appdata:
and make sure you have access to directory where the image is stored. 使用
ms-appx:
而不是ms-appdata:
并确保您可以访问存储图像的目录。
You can use Assets
directory to store the images and easily use it in the code. 您可以使用
Assets
目录存储图像,并在代码中轻松使用它。
For eg: Source="ms-appx:///Assets/LoadingImage.png" />
例如:
Source="ms-appx:///Assets/LoadingImage.png" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.