我已經看了大約十幾個不同的解決方案,以得到它的工作,我似乎無法正確執行它。我有一個文件cup.png,放置在名爲/ Images /位於我的項目文件夾「/ Visual Studio 2013 \ Projects \ PointOfSale \ PointOfSale \ Images \ cup.png」下的子文件夾中。C#的相對路徑圖像不會工作
的IDE就像它可以找到文件,並在設計視圖,一切都顯示出來了,我可以編譯,但我跑得它一刻起,我得到一個XamlParseException錯誤:
A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll Additional information: 'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '7' and line position '14'.
什麼我在這裏錯過的世界?我已經嘗試了所有不同形式的這些嘗試,並得到這個工作:
<ImageBrush ImageSource="pack://application:,,,/PointOfSale;component/cup.png" Opacity="0.1"/>
<ImageBrush ImageSource="/cup.png" Opacity="0.1"/>
<ImageBrush ImageSource="/Images/cup.png" Opacity="0.1"/>
<ImageBrush ImageSource="/PointOfSale;component/Images/cup.png" Opacity="0.1"/>
您是否想要將圖像嵌入到二進制文件中,或作爲相對於可執行文件的文件夾中的外部資源? –
基本上,我需要壓縮整個解決方案文件夾並將其發送給某人,並且我想確保程序可以加載圖像文件,因爲它是主窗口的背景圖像。我需要它從解決方案文件夾中的某個文件夾加載文件,而不需要整個路徑(C:\ users \ ... \ documents \ visual studio \ etc ....) –