Skip to content

edsnider/htmllabel

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
art
 
 
src
 
 
 
 
 
 
 
 
 
 

HTML Label for Xamarin.Forms apps

Build status MyGet NuGet

Easily render HTML in your Xamarin.Forms apps.

Note: This control is intended for basic text formatting (e.g., bold, italic, hyperlinks, etc.). It is not intended for rendering complex HTML or webpages - use the WebView for that.

Dependency

  • Xamarin.Forms >= 3.0.0.446417

Supported platforms

HtmlLabel is supported on the following Xamarin.Forms platforms:

  • iOS
  • Android

Usage

You use HtmlLabel just like any other control on a Xamarin.Forms ContentPage.

The value of the Text property will be rendered as HTML using the platform's native text formatting approach.

XAML example

<ContentPage 
    ...  
    xmlns:controls="clr-namespace:XamForms.HtmlLabel;assembly=XamForms.HtmlLabel">

    <StackLayout VerticalOptions="CenterAndExpand" HorizontalOptions="Center" WidthRequest="250">
        
        <Entry Text="" Placeholder="Username" />
        <Entry Text="" Placeholder="Password" />
        <Button Text="Sign in" BackgroundColor="Purple" TextColor="White" />
        
        <controls:HtmlLabel Text="Upon sign in you agree to our &lt;a href='http://www.infernored.com'&gt;Terms of Service&lt;/a&gt; and &lt;a href='http://www.infernored.com'&gt;Privacy Policy&lt;/a&gt;." />

        <!-- Or, with data binding -->
        <controls:HtmlLabel Text="{Binding SignInAgreementText}" />

    </StackLayout>

</ContentPage>

When using this control in XAML it is recommended you use XAMLC.

C# example

var signInLinks = new HtmlLabel
{
    Text = @"Upon sign in you agree to our <a href=""http://www.infernored.com"">Terms of Service</a> and <a href=""http://www.infernored.com"">Privacy Policy</a>."
};

License

Licensed under MIT. See License file