Welcome Guest Search | Active Topics | Sign In | Register

How to use proxy by WebView.Preload method Options
NaHack
Posted: Saturday, April 6, 2019 9:22:18 AM
Rank: Newbie
Groups: Member

Joined: 4/6/2019
Posts: 1
My C#WPF project have two windows, main window have a button.when click this button,will show the second window.the second window contain a webcontrol.

One problem is that the webview not be loaded until the second window is displayed.So I want to use WebView.Preload method.I want to use Engine profiles in webview, but the WebView.Preload method return default Engine.

How to solve this problem?
eo_support
Posted: Monday, April 8, 2019 8:32:51 AM
Rank: Administration
Groups: Administration

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

You won't be able to use a different Engine with WebView.Preload. However if you just want to use a different proxy but is OK with using the default engine, you can set the Proxy on EO.WebEngine.EngineOptions.Default before you call WebView.PreLoad.

You can also use WindowInteropHelper.EnsureHandle() to ensure the handle is being created for your second window before you display it. The WebView will be created when the window handle is created.

Thanks!
NaHack
Posted: Monday, April 8, 2019 10:47:26 AM
Rank: Newbie
Groups: Member

Joined: 4/6/2019
Posts: 1
eo_support wrote:
Hi,

You won't be able to use a different Engine with WebView.Preload. However if you just want to use a different proxy but is OK with using the default engine, you can set the Proxy on EO.WebEngine.EngineOptions.Default before you call WebView.PreLoad.

You can also use WindowInteropHelper.EnsureHandle() to ensure the handle is being created for your second window before you display it. The WebView will be created when the window handle is created.

Thanks!


Hi,I use WindowInteropHelper.EnsureHandle() in a demo project,But it still doesn't load the page until the window opens.

MainWindow(.cs):

EOWindow eoWnd;
public MainWindow()
{
InitializeComponent();
eoWnd = new EOWindow();
var eoWndHand = new System.Windows.Interop.WindowInteropHelper(eoWnd);
eoWndHand.EnsureHandle();
}

private void button_Click(object sender, RoutedEventArgs e)
{
eoWnd.Show();
}



EOWindow(.xaml)

<eo:WebControl>
<eo:WebControl.WebView>
<eo:WebView Url="https://www.google.com/"></eo:WebView>
</eo:WebControl.WebView>
</eo:WebControl>

eo_support
Posted: Wednesday, April 10, 2019 10:01:43 AM
Rank: Administration
Groups: Administration

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

We have confirmed that WindowInteropHelper indeed does not work. This is because WebControl relies on a HwndHost element and that element does not create its window handle unless the parent window is shown.

The following code uses Preload to load the WebView using the default engine. So if you must set proxy setting, you can set the proxy setting on the default Engine. Our next build will allow you to change proxy setting at any time without having to restart the engine (this can already be done in the current build but there is a bug that needs to be avoided, this bug will be fixed in our next build).

Code: C#
public partial class TestWindow : Window
{
    private EO.WebBrowser.WebView webView;

    public TestWindow()
    {
        InitializeComponent();
        var preloadTask = EO.WebBrowser.WebView.Preload("http://www.google.com");
        preloadTask.OnDone(() =>
        {
            webView = preloadTask.WebView;
            if (this.IsLoaded)
                webControl.WebView = webView;
        });
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        if (webView != null)
            webControl.WebView = webView;
    }
}


XAML:

Code: XML
<Grid>
    <eo:WebControl x:Name="webControl">
    </eo:WebControl>
</Grid>


Note that in the XAML there is no WebView because the WebView is set dynamically in the code.

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.