Click here to Skip to main content
15,895,283 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Friends,

I created one sample WPF application using a TabControl and WebBrowser control. I have 5 Tab Items. Each tab items content is one browser instance.

Now when i run the application, the first browser instance fired the Loadcompleted event, remaining 4 instances is not firing that event.

The Loadcompleted event is firing only while activating the corresponding tab items. Please let me know how to fire the load completed event on application load.


for (int i = 0; i < 5; i++)
{
TabItem item = new TabItem();
WebBrowser WebBrowser1 = new WebBrowser();

WebBrowser1.LoadCompleted += new LoadCompletedEventHandler(WebBrowser1_LoadCompleted);

WebBrowser1.Navigate(@"C:\BrowserSample1\HTMLPage1.htm");
item.Content = WebBrowser1;



// tabs == Tab Control in XAML
tabs.Items.Add(item);
}

void WebBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
{
// throw new NotImplementedException();

// Load completed
}


Regards,
Nidheesh
Posted
Updated 25-Jul-13 22:04pm
v2
Comments
Sergey Alexandrovich Kryukov 26-Jul-13 3:03am    
As you didn't show how you tried to handle this event, you code sample does not make sense. Show it, and we'll see if you are really handling it or not.
—SA
nidheesh.k 26-Jul-13 4:05am    
Question updated. Please check

Regards,
Nidheesh
Sergey Alexandrovich Kryukov 26-Jul-13 8:48am    
Thank you for the update. Okay, and how do you know it's not invoked. Did you put a breakpoint on the handler code (which does nothing)?
—SA
Varsha Ramnani 26-Jul-13 5:27am    
WPF only renders controls when visible thats UI virtualization.
So tab items content are rendered when the tab is selected (when they are visible) that is the reason loadcompleted event is not executed for all the Webbrowser controls in tabs when your application or windows is loaded.
Sergey Alexandrovich Kryukov 26-Jul-13 8:47am    
"Renders", but it does not mean not invoking events. I can check it up, but this event is non a visual event, should be invoked anyway.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900