首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BitmapImage异常

BitmapImage异常
EN

Stack Overflow用户
提问于 2015-04-07 18:23:48
回答 1查看 1.7K关注 0票数 3

以下是我的XAML代码:

代码语言:javascript
复制
<Image Stretch="Fill" Margin="15,0,0,0" ToolTip="{Binding ImagePath}" Width="110" Height="100" >
  <Image.Source>
   <BitmapImage RenderOptions.BitmapScalingMode="LowQuality" CacheOption="OnLoad" DecodePixelWidth="200" CreateOptions="IgnoreColorProfile" UriSource="{Binding ImagePath ,FallbackValue={StaticResource Lost},TargetNullValue={StaticResource Lost}}"/>
  </Image.Source>
</Image>

这给了我一个错误:

System.Windows.Markup.XamlParseException类型的未处理异常发生在PresentationFramework.dll中 附加信息:初始化“System.Windows.Media.Imaging.BitmapImage”会引发异常。

有时,UriSource获得空路径或无效路径时,我希望显示默认图像

EN

回答 1

Stack Overflow用户

发布于 2019-05-24 12:41:50

BitmapImage throws an initialization exception when file does not exist

这个答案对我有效,也适用于你遇到的同样的问题。如果图像文件丢失,我可以使用转换器返回我想要的图像。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29498515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档