My question is: am I reading MSDN incorrectly OR incorrect MSDN? I am trying to reference an image resource through a relative URI.
The MSDN page called Pack URIs in WPF clearly states that:
"Resource file in a subfolder of the local assembly" = " /Subfolder/ResourceFile.xaml "
Table 2: Relative URIs in the markup (here http://msdn.microsoft.com/en-gb/library/aa970069.aspx ).
So, I created new WPF / .NET 4.0 projects in Vs2010 (v10.0.40219.1 SP1Rel) for testing.
Startup Project: TryUri App.xaml MainWindow.xaml Custom Ctrl Project: TryUri.CCL Icons/folder.png <-- Marked As Resource! Views/TestUC.xaml
In TestUC.xaml:
<Canvas> <Border> <Image Source="/Icons/folder.png" Height="Auto" Width="Auto" /> </Border> </Canvas>
In MainWindow.xaml:
// xmlns:uc="clr-namespace:TryUri.CCL.Views;assembly=TryUri.CCL" <uc:TestUC />
Result: the image does not appear!
When I change the path to "../Icons/folder.png" It works.
If I copy Icons / folder.png to the TryUri.CCL / Views / folder, then "Icons / folder.png" works.
However, I can never get the leading slash to work the same as in "/Icons/folder.png," as stated by MSDN.
Wayne bloss
source share