Welcome Guest Search | Active Topics | Sign In | Register

How to load content in browser before opening? Options
anninkov
Posted: Friday, July 7, 2017 10:35:37 AM
Rank: Member
Groups: Member

Joined: 7/7/2017
Posts: 13
Hello, support!

I have created WPF application. It has some tabs, each of which contains webBrowser element:
=================================
<eo:WebControl>
<eo:WebControl.WebView>
<eo:WebView x:Name="webBrowser">
</eo:WebView>
</eo:WebControl.WebView>
</eo:WebControl>
=================================

When my application starts, I try to load particular resource in every webBrowser:
=================================
EO.WebBrowser.Request request = new EO.WebBrowser.Request(url);
request.Method = "POST";
webBrowser.LoadRequest(request);
=================================

As I have discovered, browser's element starts to load url only if appropriate tab was selected.

Is there a method to load resource in browser before tab was selected?

Please advice.

Sincerely,
Dmitry Anninkov.
eo_support
Posted: Friday, July 7, 2017 8:49:24 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,225
Hi,

Do not place the WebControl directly in the TabControl. In order for the WebControl starts to function, its window handle must be created, which requires the WebControl to be connected to the visual tree. A TabControl does not connect all tabs to the visual tree, it only connects the current tab to the visual tree. This causes only the WebControl in the selected tab works.

You can use the following method to workaround this issue:

1. Instead of placing the WebControl inside the TabControl, place them inside a Grid. The TabControl will contain the tab header only. So the visual tree will be like this:

Code:
Window
  +--TabControl
  |    +--TabHeader1
  |    +--TabHeader2
  +--Grid
       +--WebControl1
       +--WebControl2


2. Handle the TabControl's SelectionChanged event. Inside the event handler you can dynamically set only one WebControl inside the Grid to Visible (set its Visibility to Visible and set all others to Hidden) based on the TabControl's SelectedIndex property.

Our TabbedBrowser sample uses a similar technique. Instead of using a Grid, we uses our own DockView class (m_WebViewsHost in MainWindow.xaml.cs), which works very similar to a Grid control on this regard. Internally a DockView uses a Grid to holds all Items and setting a DockView's SelectedIndex sets the item at the specified index to Visible and all other items to Hidden.

Hope this helps. Please feel free to let us know if you still have any questions.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.