简体   繁体   English

如何从另一个项目绑定UWP项目图像?

[英]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.

相关问题 如何在本地项目文件夹中的Datagridview Windows窗体中绑定图像 - How to bind image in datagridview windows forms from local project folder 绑定到同一解决方案中另一个项目的属性 - Bind to property from another project in same solution 如何在相同的解决方案中将menuitem绑定到另一个项目 - how to bind menuitem to another project in same solution 从UWP项目引用.NETStandard 2.0项目 - Reference a .NETStandard 2.0 project from UWP project 引用.NET核心项目中的UWP项目 - Reference a UWP project from a .NET core project asp.net mvc如何将业务逻辑从另一个项目绑定到我的asp.net mvc项目 - asp.net mvc how to bind business logic from another project to my asp.net mvc project Xamarin 如何将类属性(来自另一个项目)绑定到 Picker.ItemDisplayBinding 属性 - Xamarin How to bind a class property (from another project) to the Picker.ItemDisplayBinding property 如何使用另一个项目中的枚举将单选按钮组绑定到枚举属性? - How can I bind a radio button group to an enum property using an enum from another project? 如何在 UWP 项目中将 comboBox 绑定到与其父 DataGrid 的 ItemSource 不同的 ItemsSource? - How do I bind a comboBox to a different ItemsSource than it's parent DataGrid's ItemSource in a UWP project? 如何从 UWP 项目调用 WPF 项目中存在的函数 - How to call functions present in WPF projects from UWP project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM