c# - CefSharp WPF and MVVM? -


i using cefsharp wpf. want use in mvvm architecture. unfortunately there problem. in view have:

<contentpresenter content="{binding browser}"                   horizontalalignment="center"                   verticalalignment="center"/> 

in viewmodel put new object browser:

var settings = new cefsharp.settings {     packloadingdisabled = true, } if (cefsharp.cef.initialize(settings)) {     int counter = 0;     this.browser = new webview(); } 

unfortunately cannot load url @ point after that. says browser not initialized , isbrowserinitialized property (in browser) false.

that weird because in test app, not mvvm, used same code instantiate webview works. difference programmatically added browser grid not mvvm.

anyone got cefsharp in wpf mvvm app? ideas?

thanks

edit: have noticed in test non-mvvm app, isbrowserinitialized property set false until window constructor ends job.

cefsharp version 1 not suited mvvm @ moment, unfortunately. luckily, in cefsharp 3 have tried make more "mvvm-aware" don't have lot of hacks. see cefsharp.wpf.example code there , (hopefully) see mean.

the way working cefsharp version 1.xx set propertychanged event handler. once isbrowserinitialized property gets set true, can work. this:

    webview.propertychanged += onwebviewpropertychanged;      // ...      private void onwebviewpropertychanged(object sender, propertychangedeventargs e)     {         switch (e.propertyname)         {             case "isbrowserinitialized":                 if (webview.isbrowserinitialized)                 {                     webview.load("http://some/url");                 }                 break;         }     } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -