Silverlight webbrowser control - silverlight

Is there a way to fire an event when the user clicks on link on a web page. I looked at all the events available for the webbrowser control and the only one I saw was the LoadCompleted event. But this event fires after a page has been loaded. I need to fire an event right before a page is loaded.

Without some co-operating javascript in the web page there is no way to acheive this.
If the web page(s) being displayed are something you control you can add some javascript to the page like this:-
window.external.notify("Page is doing xyz");
you can then use the controls ScriptNotify event to retrieve the string sent by the notify.
You could add such script in the web page onunload event or the onclick event of an anchor, etc.

Related

Add a new page at runtime in WPF on button click

In my application I need to create a new XAML page/usercontrol at runtime. The use case is like:
User Clicks on add page button on the main window.
A new XAML page gets added to the application.
User can design the page by adding controls from a custom tool bar and save the page.
User can also add event handler to navigate between pages.
Please let me know how can I go about this.

First click doesn't work after navigating to a page

I have a Silverlight application that is using the Navigation Framework. The page is never focused right after it is navigated too. So when I first click on a button, it does nothing (except focus the page). Only the second click after navigation works. I use a subclass of the Page and have hooked the GotFocus event. It is never called. I've also tried to call the Focus method a handler for the Loaded event and the override to OnNavigatedTo. Nothing works. The GotFocus handler is never called until I actually click somewhere in the view. My clients are not going to accept this. Is this a bug with the Navigation Framework, is there a work around?
Thanks for you help.

How do I do something at the end of a page animation from the Silverlight Toolkit for Windows Phone?

I am using the August 2011 SilverlighT Toolkit to do a page animation. I have defined the animation in a Style that I apply to the page.
There is a UI element that I only want displayed once the animation has finished. I thought I could just set its IsVisible property to true, but when? Is there an event that I can subscribe to or something? How do I access the transition from the style?
By saying when the animation has finished, do you mean when you page is loaded? You could use the Loaded event on the page. The users can access the ui elements only when the page are loaded. There is also onNavigatedTo event.

Silverlight App inside WPF WebBrowser?

I have a hopefully trivial question. Currently, my company works with a rather obscure language (SyngergyDE) and we need to call a SilverLight application inside our product. Unfortunately, this obscure 3rd party language only (currently) supports the opening of WPF screens. So with that said, I thought I'd develop a small WPF user control that contains a "WebBrowser" control and navigate to the silverlight application's URI. This works fine, and I'm able to see the SL application. Here is my question - we have a "Close" button on the SL application, and when users "Click" that button, we want the window to close.
Does anyone have any suggestions on how we can communicate the "Closing of the SL App" to the WPF user control, so that the entire WPF user control closes as well?
Thanks everyone,
-Tom
Attach an event handler to the WebBrowser.Navigated event.
Have the close button in the Silverlight application use:-
HtmlPage.Window.Navigate(new Uri("about:blank", UriKind.Absolute));
When the Navigated event fires in WPF with the url "about:blank" then its time to close the control.
Use Javascript and the HTML DOM as the glue here.
For example, when the SL app close button is clicked, have Silverlight trigger some Javascript code that sets a flag, or alternately, raises some HTML document event.
The WPF control could poll that flag in the HTML + Javascript, or alternately listen for that HTML document event, then close the user control.

Do WPF hyperlinks only work in pages?

I'm new to the Hyperlink control. I wish to have a hyperlink in a regular WPF window which will navigate to a URL by opening the standard browser. I have added the hyperlink, but it does nothing.
Before I implement a handler to do the work myself, can anyone please confirm that the Hyperlink control will navigate only within pages?
You will need to do it yourself.
The simplest way to do it is to handle the Hyperlink.RequestNavigate event and call Process.Start with the URL. (This will open the default browser).

Resources