views:

4109

answers:

2
+2  Q: 

WPF Frame control

I have a WPF application containing a Frame control. The frame control displays the html content. The html page contains a javascript function which i want to call after html page is loaded on Frame and from the WPF code ? Is there a way i can call javascript mehtod of html page loaded in WPF frame control and from within WPF code?

+1  A: 

There's no access to the DOM, so it's a no go I'm afraid. If it's something you definately need then your best bet is probably to embed the WinForms WebBrowser control from System.Windows.Forms.

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:f="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" 
  xmlns:fi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration.dll" >
  <Grid>  
    <fi:WindowsFormsHost>
      <f:WebBrowser x:Name="BrowserControl" Url="http://www.myurl.com/"/&gt;
    </fi:WindowsFormsHost>
  </Grid>
</Page>
Steven Robbins
+2  A: 

You can't interact with the HTML inside of a frame. In order to interact with HTML, you can use WPF's WebBrowser control of .NET 3.5 SP1.

You can see in WebBrowser control in action in this video:

http://channel9.msdn.com/posts/AdamKinney/WPF-35-SP1-App-Model-with-Jennifer-Lee/

eriawan