Extended webbrowser in Windows phone to support binding HTML content

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.