1

I've got a DotNetBrowser instance defined in a XAML file

<Grid>
  <wpf:WPFBrowserView x:Name="BrowserView"></wpf:WPFBrowserView>
</Grid>

The application is used by multiple people, which is causing issues due to the issue discussed here:

Chromium profile directory is already used/locked by another browser

Is it possible to use XAML to define the browser control and still assign a custom context to the browser instance?

Steve Mitcham
  • 5,268
  • 1
  • 28
  • 56

2 Answers2

2

Is it possible to use XAML to define the browser control and still assign a custom context to the browser instance?

No, I am afraid it's not.

The Browser property of the WPFBrowserView class doesn't have a public setter so you must create the custom Browser and the BrowserContext programmatically:

BrowserContextParams params1 = new BrowserContextParams("C:\\my-data1");
BrowserContext context1 = new BrowserContext(params1);
Browser browser1 = BrowserFactory.Create(context1);

XAML doesn't support anything like calling BrowserFactory.Create(context1).

mm8
  • 163,881
  • 10
  • 57
  • 88
0

Unfortunately, the custom BrowserContext can be configured only if the Browser and WPFBrowserView were created from the source code.

The possible approach is to wrap WPFBrowserView and its non-default initialization into a custom control that manages instantiating and disposal of the WPFBrowserView, make this control expose all the necessary properties and then insert it into your XAML.

Anna Dolbina
  • 1
  • 1
  • 8
  • 9