Click here to Skip to main content
15,074,377 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi,
after SAKryukov gave me the advice to try video playing in WPF I ventured programming WPF. It is very easy, I am amazed.
But in the past I forced myself to work with folders in the solution explorer for content and work with relative paths. But I think it doesnt work in XAML.
Heres my problem code:

<mediaelement canvas.left="0" canvas.top="0">
Name="VideoControl" LoadedBehavior="Manual"
UnloadedBehavior="Stop"
Source="~/Content/..."
Stretch="Fill">


Can anyone tell me how to use a relative path?

Thanks,
Vince
Posted

1 solution

Typically it's done as:

XML
Source="/Content/SomeFolder/MyMedia.ext"
   
Comments
ilia.broudno 27-Mar-14 12:58pm
   
Can you explain why it works?
How does this relative path gets resolved and by what?
What is this path relative to?
I placed Pics directory in the same folder as project file and I can access it via @"/Pics/blabla" syntax in code even though the executable is actually 2 levels down (bin\Debug) from the project file.
When the project is deployed (installed via installshield), /Pics is placed on the same level as executable but it still works.
Which should be exactly what I want but unfortunately it does not work for all such references and I can't figure out why without knowing how the resolving is actually done.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900