WPF win app .HTML resource, How to path to images in the .html .resource
I have a working WPF .exe that currently pulls a .resource (.html) file into a web browser embedded control. My issue is pathing any image references within this HTML resource. All assets are local to this project and can be embedded within the project.
I am curious as to HOW to do image and or .JS references and/or best practices. I am new to WPF, so I usually work from the code side as opposed to doing things on the XAML side.
Uri HTMLuri = new Uri(@"pack://application:,,,/MYPROJECT;component/Resources/help.html", UriKind.Absolute);
Stream stream = Application.GetResourceStream(HTMLuri).Stream;
using (StreamReader reader = new StreamReader(stream))
{
this.wbHelp.NavigateToString(reader.ReadToEnd());
}
I have read several articles around the web on this 'similar' topic but the contexts were not correct (necessarily) for what I'm trying to accomplish. Question: How do I path HTML assets within an .HTML .resource file in a standalone WPF Win APP? Thanks in advance for any responses.
The answer will most likely not be to your liking. I spent a long time trying to crack this very problem, but (unless something changed in the latest .NET 4.5 WebBrowser
control) unfortunately, this is not possible. The reason is because this control will run in its own context with absolutely no connection to the rest of your WPF project.
上一篇: 托管的WPF控件中的嵌入式图像资源