I’m having a problem with WebBrowser control in WP7. Can anyone explain to me why does example 1 works and example 2 doesn’t?
Example 1:
XAML
<Grid x:Name="grForWebBrowser">
<phone:WebBrowser Name="wb"/>
</Grid>
CodeBehind
const string html = "<html><h2>TEST</h2></html >";
wb.NavigateToString(html);
Example 2:
XAML
<StackPanel x:Name="spForWebBrowser"/>
CodeBehind
WebBrowser wb = new WebBrowser();
const string html = "<html><h2>TEST</h2></html>";
wb.NavigateToString(html);
spForWebBrowser.Children.Add(wb);
Thank you for any advice.
Your code does work. You just haven’t set the width and height properties of the webBroswer so it is defaulting to 0 x 0
You could also control the size of the WebBrowser using Margins, but for the sake of explanation I explicitly set it’s dimensions.