☰ Brand

Persian Programmer

Persian Programmer ×
Home About Us Services and Pricing Contact Us My Resume Co-worker

Xamarin.Forms 3.3.0: Little Things, Huge Difference

Xamarin.Forms 3.3.0: Little Things, Huge Difference

The Xamarin.Forms team has been working closely with our open-source community to help fill in the “little things”. Things you’ve told us are important to building your mobile apps and being supremely productive in the process. Since Xamarin.Forms 3.0 shipped at Build 2018, we have been collaborating with you to deliver over 20 new features and fixes. With many more on the roadmap!

The three most often used controls in mobile applications are buttons, images, and labels. They are just about everywhere! It’s no wonder we shipped the Android Fast Renderers for those back in 2.4.0 with the main focus being on improved layout performance. Which is why that Label continues to get a lot of focus in this Xamarin.Forms 3 series of “little things” enhancements. In this post, we’ll highlight those updates, give you a taste of what’s happening for Android image performance, and show you how to update your WebView  for optimal performance on iOS.

More Label Love

In the past few releases of Xamarin.Forms, Labels have been getting some serious upgrades thanks to community contributions that added bindings and gestures to spans. Now, thanks to Alan Grgic’s contribution, you can easily add text decorations such as underline and strike-through. Combine everything together, and you’ve got the coveted inline hyperlink!

<Label>
    <Label.FormattedText>
        <FormattedString>
            <FormattedString.Spans>
                <Span Text="This app is written in C#, XAML, and native APIs using the" />
                <Span Text=" " />
                <Span Text="Xamarin Platform" FontAttributes="Bold" TextColor="Blue" TextDecorations="Underline">
                    <Span.GestureRecognizers>
                       <TapGestureRecognizer 
                            Command="{Binding TapCommand, Mode=OneWay}"
                            CommandParameter="https://docs.microsoft.com/en-us/xamarin/xamarin-forms/"/>
                     </Span.GestureRecognizers>
                </Span>
                <Span Text="." />
            </FormattedString.Spans>
        </FormattedString>
    </Label.FormattedText>
</Label>

That’s not all. Gerald Versluis has contributed the ability to set the maximum number of lines you wish a label to render. This is super useful for doing things such as displaying a few lines and adding a “read more” to expand the full text.

<Label x:Name="TruncatedLabel" 
    MaxLines="4" 
    LineBreakMode="TailTruncation" 
    Text="You should see 4 lines of text and truncation at the end. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam mattis quam non enim pellentesque, ut placerat purus finibus. Nulla quis tincidunt ante. Ut mauris lectus, aliquam a sagittis vitae, consequat eget elit. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque convallis nunc nisi, a imperdiet elit efficitur et. Duis in lectus mollis, interdum ipsum et, tincidunt orci. Fusce ipsum metus, imperdiet non lacus vitae, facilisis feugiat magna. Nulla volutpat nisl tortor, a consectetur felis consectetur non. Curabitur in enim vulputate sem volutpat bibendum id nec lorem. Mauris laoreet lacus ac volutpat tempus."/>
<Button x:Name="ReadButton" 
    Text="[read more]" 
    Clicked="Button_Clicked" />

Android Image Performance and Memory Boost

To better support future efforts of image handling, we have introduced the new IImageViewHandler . You can combine this new interface with the Android Glide library made available as GlideX for Xamarin.Forms by our own Jonathan Peppers. And we have the performance benchmarks to tell the real story!

Below you can check the memory allocation results between a default Xamarin.Forms app and a Xamarin.Forms app that leverages the GlideX library.

Page
Loaded by
Peak Memory Usage (bytes)
GridPage
Xamarin.Forms
268,387,112
GridPage
glidex.forms
16,484,584
ViewCellPage
Xamarin.Forms
94,412,136
ViewCellPage
glidex.forms
12,698,112
ImageCellPage
Xamarin.Forms
24,413,600
ImageCellPage
glidex.forms
9,977,272
HugeImagePage
Xamarin.Forms
267,309,792
HugeImagePage
glidex.forms
9,943,184

We look forward to bringing additional performance improvements to images in Xamarin.Forms. The Team is actively investigating more tightly integrating GlideX so you can get the best performance experience by default.

WebView Updated for iOS

iOS has used the UIWebView for displaying a web browser control since iOS 2, and it provides Xamarin.Forms with the best backward compatibility when you use the WebView control. With iOS 8.0, Apple introduced WKWebView, and this is now available as an option for you when using in Xamarin.Forms 3.3.0. WKWebView  runs Safari in a separate process and provides better performance, especially when you need to execute JavaScript.

To use the WKWebView  instead of the UIWebView  you have to add this directive to your AssemblyInfo.cs:

[assembly: ExportRenderer(typeof(WebView), typeof(WKWebViewRenderer))]

Get Started Today!

Check the full release notes for all the details, and we would encourage you to explore the documentation. Xamarin.Forms 3.3.0 includes more than 30 bug fixes and ships just 30 days after 3.2.0 meaning you don’t have to wait long to benefit from all those quality improvements.

This update is now available on NuGet and via your Visual Studio package manager:

Find an issue or have a suggestion?

We would encourage everyone to engage with us on GitHub and report any new issues or make suggestions here: https://github.com/xamarin/Xamarin.Forms/issues/new.

If you want to find out what we are working on right now, then you can explore our sprint project boards on GitHub. Finally, if you’re curious about what comes next and want to help us shape Xamarin.Forms then you can visit the Xamarin.Forms Feature Roadmap and let us know what you think.

0 comments

answer