为什么XAML图像源属性包含“/ MyApp; component”?
发布时间:2020-12-13 20:12:42 所属栏目:Windows 来源:网络整理
导读:我正在开发 Windows Phone应用程序. 我正在使用图像,当我使用“属性”面板选择图片时,我得到以下XAML: Image x:Name="GameImage" Margin="8" Source="/MyApp;component/Assets/Icons/GameImage.png"/ 为什么我得到“/ MyApp;组件/ …”? (有更好的方法吗?
我正在开发
Windows Phone应用程序.
我正在使用图像,当我使用“属性”面板选择图片时,我得到以下XAML: <Image x:Name="GameImage" Margin="8" Source="/MyApp;component/Assets/Icons/GameImage.png"/> 为什么我得到“/ MyApp;组件/ …”? (有更好的方法吗?) 如果我尝试做Image.Source =“资产/图标/ GameImage.png”为什么它不起作用?
这是因为您的图像将其构建操作设置为资源(这是默认值).如果将其切换到内容,您可以像XAML那样设置源:
<Image x:Name="GameImage" Margin="8" Source="/Assets/Icons/GameImage.png"/> 要设置代码,你可以这样做: BitmapImage tn = new BitmapImage(); tn.SetSource(Application.GetResourceStream(new Uri(@"Assets/Icons/GameImage.png",UriKind.Relative)).Stream); Image.Source = tn; 出于性能原因,您应该使用内容.请参阅这篇文章了解更多细节:http://www.windowsphonegeek.com/tips/wp7-working-with-images-content-vs-resource-build-action (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-server-2008-r2 – 事件ID 10009 DCOM
- windows – OpenGL GLEW MinGW应用程序链接问题
- Windows 设置定时任务
- wpf – 在Windows桌面和Windows Store应用程序之间共享字符
- windows – 使用Delphi查找特殊驱动器
- windows-server-2008 – 访问被拒绝的问题,Windows Server
- windows – 为什么TClientSocket.OnRead事件为单个服务器发
- .net – WPF应用程序失去了触摸功能
- msmq – 有没有办法只查看计算机管理的消息队列部分?
- windows-phone-7 – 目标WP7和WP8.1(8.0设备将获得WP7应用程
推荐文章
站长推荐
热点阅读