views:

13

answers:

1

Hi, For a rather large project i have to figure out how (if possible) to resolve this problem. I have a full screen WPF application doing a slideshow - following an interval of e.g. 20 secs per slide. Now I have to investigate into the possibility of replacing the slideshow with a URL instead and have the user navigate the slides instead of changing slides every 10 seconds. The setup is like this:

  1. First the timed slideshow will run, e.g. 5 slides
  2. I show my web page and lets the user interact with the website (navigating)
  3. When the user "Does something (this is the problem)" the website is removed from "slide" and the original slideshow is resumed

The container being shown is a WPF UserControl with an event that allows it to change to the next slide (call a Next() method). The IExporer is hosted within this control.

The problem im facing is this: how do i communicate from the website that my hosting application has to call the NExt() method?

The IExplorer showing the website is hosted within my WPF UserControl. Is there any way i can access some kind of event or anything else to help me determine if a particular page or a particular link has been pressed??

WebServices, files on disc, you name it, im ready to try anything :-)

Any advice or possible solution is appreciated.

A: 

If you use the WebBrowser control in your WPF application, you can call into C# classes using javascript from your html. For example, let's say you have a class similar to the following:

[ComVisible(true)]
public class JavaScriptBackEnd
{
    public void onclick(string s)
    {
        MessageBox.Show(s);
    }
}

Then initialize the WebBrowser control with the following code:

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    webBrowser1.ObjectForScripting = new JavaScriptBackEnd();
    webBrowser1.Navigate(new Uri(@"HTMLPage1.htm"));
}

From HTMLPage1.htm you can now call the JavaScriptBackEnd.onclick method with the following javascript:

function testclick() {
    window.external.onclick('blabla');
}
Jakob Christensen
Nice! just what i needed
H4mm3rHead