WPF-13:资源文件需要手动引用问题
2013-04-08 17:57
260 查看
最近碰到一个问题。
两个自定义控件,其中用到图片,即<Image Source="图片路径" />。
控件1:
控件2:
调用该控件:
区别在于第一个控件的Source="TestImageSource;component/Images/laugh.gif" 是手动填写。第二个则是,属性-source-选择图片。
结果造成,作为控件使用时,控件1无法显示图片,控件2正常显示图片。如下:
不知是本地环境有问题还是原本如此,所以同样使用的需要注意了,还是手动选择图片吧。
代码下载:http://download.csdn.net/detail/yysyangyangyangshan/5234502
本文出自 “西北白杨树” 博客,请务必保留此出处http://yangyoushan.blog.51cto.com/7229571/1276414
两个自定义控件,其中用到图片,即<Image Source="图片路径" />。
控件1:
<UserControl x:Class="TestImageSource.UserControl1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> <Grid> <Image Source="TestImageSource;component/Images/laugh.gif" /> </Grid> </UserControl>
控件2:
<UserControl x:Class="TestImageSource.UserControl2" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300"> <Grid> <Image Source="/TestImageSource;component/Images/laugh.gif" /> </Grid> </UserControl>
调用该控件:
<Window x:Class="TestImageSource.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="520" Width="1022" xmlns:my="clr-namespace:TestImageSource"> <Grid> <my:UserControl1 HorizontalAlignment="Left" Margin="21,12,0,0" x:Name="userControl11" VerticalAlignment="Top" Height="267" Width="423" /> <my:UserControl2 HorizontalAlignment="Left" Margin="540,58,0,0" x:Name="userControl21" VerticalAlignment="Top" Height="320" Width="411" /> </Grid> </Window>
区别在于第一个控件的Source="TestImageSource;component/Images/laugh.gif" 是手动填写。第二个则是,属性-source-选择图片。
结果造成,作为控件使用时,控件1无法显示图片,控件2正常显示图片。如下:
不知是本地环境有问题还是原本如此,所以同样使用的需要注意了,还是手动选择图片吧。
代码下载:http://download.csdn.net/detail/yysyangyangyangshan/5234502
本文出自 “西北白杨树” 博客,请务必保留此出处http://yangyoushan.blog.51cto.com/7229571/1276414
相关文章推荐
- WPF-13:资源文件需要手动引用问题
- WPF 文件级资源(类似与使用CSS文件,然后引用CSS文件)
- 详谈vue+webpack解决css引用图片打包后找不到资源文件的问题
- vue+webpack解决css引用图片打包后找不到资源文件的问题
- 莫名其妙的 Silverlight资源文件引用问题
- WPF使用路径(URI)引用资源文件
- 安装matlab到99%时出现的问题:在您的许可证文件中找不到 SERVER 行。您需要在 "......" 中手动编辑 SERVER
- android studio drawable文件下xml 引用 mipmap 资源文件问题
- wpf 图片资源引用问题
- WPF 提示"该密钥文件可能受密码保护。若要更正此问题,请尝试再次导入证书,或手动将证书安装到具有以下密钥容器名称的强名称"的解决方法
- R.java文件中的资源在Activity中得不到引用的问题
- 今天遇到一个问题才知道如果安装了命名实例 SSIS Service 需要手动更改配置文件
- wpf 引用资源文件
- 利用HttpHandler处理自定义控件中需要引用大量js文件问题
- wpf 前台获取资源文件路径问题
- WPF资源引用问题
- 莫名其妙的Silverlight资源文件引用问题
- 莫名其妙的Silverlight资源文件引用问题
- 利用HttpHandler处理自定义控件中需要引用大量js文件问题
- 网络文件资源管理系统需要引用到的第三方工具或组件