I am using webbrowser control to show local html content, cause the the background-color of the html page is black.
When I using NavigateToString method to navigate to the webbrowser, the webbrowser's background become white immediately, after a white coming the html page, then the background become black.
It's a little disturbing. Consider providing the best UX, I want to implement that the default background of the webbrowser is black.
Thx in advance.
Unfortunately this is a quirk of the WebBrowser control. I discovered the exact same issue when writing PhoneGap applications with WP7. The solution I came up with was to create a UI element that covers the WebBrowser control, wait for the content to be rendered, then fade out and hide the covering element, as described in this blog post.
Apply below code for your browser control.
public static readonly String StyleForBlackbody =
"<style type='text/css'>\n" +
" body {\n" +
" background-color : ??;\n" +
" font-size:$$px; \n" +
" font-family: ##;\n" +
" color: %%; \n" +
" };\n" +
"</style>\n";
public static String GetHtmlHead()
{
String html = StartHead;
html += StyleForBlackbody;
html = html.Replace("??", "auto");
html = html.Replace("%%", "black");
}
call above method.