[IronPython] Back to XAML, Images and Relative Locations

Michael Foord fuzzyman at voidspace.org.uk
Mon Dec 31 00:57:34 CET 2007

Hello Guys,

More adventures with  XAML, images and specifying relative locations. 
Unfortunately I have come up against what seems to be an unsolvable problem.

I want to create XAML documents that are read in with XamlReader.Load 
and read from a FlowDocumentViewer.

If these contain images then the location of the image is specified with 
a tag something like:

    <Image Source="C:\IronPythonInAction\image.jpg" />

However, (of course) I don't want to have to specify an absolute 
location. What I *want* to be able to do, is to specify an image 
location relative to the document (which seems the natural and obvious 
thing to do).

I *thought* I could do this by specifying a relative location using the 
Pack URI syntax [1]:

    <Image Source="pack://siteoforigin:,,,/Subfolder/image.jpg" />

Unfortunately that specifies a location relative to the executable of 
the current application. If executed by 'ipy.exe' then it specifies a 
location relative to 'ipy.exe'.

Unfortunately that means that, as far as I can tell, it *isn't possible* 
to load XAML files containing image references without either absolute 
file locations or text manipulation to specify the location at runtime. 
This unfortunately negates the usefulness of these documents.

Anyone know any better or have any workarounds?


[1] http://msdn2.microsoft.com/en-us/library/aa970069.aspx

More information about the Ironpython-users mailing list