I have a XAML file representing a 3D model with textures.
I want to make the textures read from the same place the file is, or relative to it.
I read the file using a XamlReader, so I want the file to be self-contained.
I place the textures using an ImageBrush which ImageSource is a pack synatx URI.
When I use a 'siteoforigin' syntax, this only works if the texture file is next to the application. I want it to be next to the Xaml, wherever it is.
I tried setting the current directory to the Xaml directory, but it didn't help.
Not using a pack syntax doesn't work as well - it just look for a resource by that name.
How do I need to write the Xaml image source (or is there another way to place textures for a diffuse material brush?) so it will work?
Itai.
I resolved this issue simply by preloading the XAML into a memory stream, replacing the siteoforigin:,,, statements with the path from which the xaml was located, and then loading the Model from the updated memory stream with XamlReader.Load
Incidently, my models are sketchup exports exported with your very own xaml exporter plugin, although I modified it to export normals and rotate the model to the WPF coordinate system, among other things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With