【发布时间】:2016-10-26 07:28:49
【问题描述】:
我在加载图像时遇到问题(仅在这台电脑上,在另一台上没问题)
我尝试了几种放置图像的方法
<Image
MinWidth="190"
Stretch="Fill"
MinHeight="190"
Source="{Binding ImagePath, Converter={StaticResource UriToImageConverter}}">
<!--If you use my way in answer you need replace Source like this-->
Source="{Binding Image}"><!--Bitmapimage property in model-->
</Image>
它只有在我放置像“ms-appx”这样的路径时才有效,但在目标中我需要使用“绑定”它在其他电脑上的工作没有任何麻烦,但这里我在页面上有“透明”图片
【问题讨论】:
-
用户选择图片,我把 'StorageFile.Path' 放到 'ImagePath'
-
你应该阅读图像文件并使用
BitmpaImage作为图像的来源。 -
@tao 我有返回位图的转换器
return new BitmapImage(new Uri(stringUri, UriKind.RelativeOrAbsolute)); -
@SmiLe 你应该使用SetSourceAsync 方法。
标签: c# xaml uwp win-universal-app windows-10-universal