c# - WebBrowser Use in WPF Not Working Correctly -
i attempting host webbrowser
in wpf
application going used display cctv camera. have 2 issues current use of it.
firstly, webbrowser
isn't behaving have come expect other wpf
ui elements. have set inside grid
, doesn't fill row / column. ends looking this;
from normal wpf
point of view have expected webbrowser
fit entire host. simple xaml
it;
<grid> <grid.rowdefinitions> <rowdefinition /> <rowdefinition /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition /> <columndefinition /> </grid.columndefinitions> <webbrowser x:name="cctvwb"/> </grid>
secondly, doesn't seem want display common web pages such google or bbc, though believe may html
, error message reads "to protect security of information enter website, publisher of content not allow displayed in frame."
this html
;
private void cctvload(object sender, routedeventargs e) { cctvwb.navigatetostring(@"<html> <head> </head> <body> <iframe src = " + "http://www.bbc.co.uk" + @"></ iframe > </body> <html>"); }
to answer first question
just remove rowdefinition
, columndefinition
xaml make webbrowser
fill entire screen. have defined grid
2 rows , 2 columns, control webbrowser
inside grid default occupies first column of first row.
to anwser second question, publiser of site doesnot allow show content in iframe
due security reasons. instead can try navigate
navigate directly url instead of having in iframe
cctvwb.navigate(@"http://www.bbc.co.uk");
Comments
Post a Comment