In WP development, WebBrowser controls are sometimes used to display some HTML content, a control that has many limitations, such as binding content not supported, so that the content can not be bound in the MVVM pattern. To achieve this, you need to extend the code as follows:
/// <summary> ///Html content Usage for binding the WebBrowser control: ext:webbrowserproperties.body= "{Binding currentarticleitem.html}"/// </summary> Public classwebbrowserproperties { Public Static ReadOnlyDependencyProperty Bodyproperty =dependencyproperty.registerattached ("Body",typeof(string),typeof(Webbrowserproperties),NewPropertyMetadata (onbodychanged)); Public Static stringgetbody (DependencyObject DependencyObject) {return(string) Dependencyobject.getvalue (Bodyproperty); } Public Static voidSetbody (DependencyObject DependencyObject,stringbody) {Dependencyobject.setvalue (bodyproperty, body); } Private Static voidonbodychanged (DependencyObject D, DependencyPropertyChangedEventArgs e) {varWebBrowser =(WebBrowser) D; Webbrowser.navigatetostring ((string) e.newvalue); } }
When used, add the following sections in the XAML code
ext:webbrowserproperties.body="{Binding currentarticleitem.html}"
You can support the binding.
Extended webbrowser in Windows phone to support binding HTML content