日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

WPF-13:资源文件需要手动引用问题

發(fā)布時間:2025/5/22 asp.net 141 豆豆
生活随笔 收集整理的這篇文章主要介紹了 WPF-13:资源文件需要手动引用问题 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
最近碰到一個問題。
兩個自定義控件,其中用到圖片,即<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>
調(diào)用該控件:
<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>
區(qū)別在于第一個控件的Source="TestImageSource;component/Images/laugh.gif" 是手動填寫。第二個則是,屬性-source-選擇圖片。
結(jié)果造成,作為控件使用時,控件1無法顯示圖片,控件2正常顯示圖片。如下:

不知是本地環(huán)境有問題還是原本如此,所以同樣使用的需要注意了,還是手動選擇圖片吧。

代碼下載:http://download.csdn.net/detail/yysyangyangyangshan/5234502

總結(jié)

以上是生活随笔為你收集整理的WPF-13:资源文件需要手动引用问题的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。