Forum Xamarin.Forms

Xamarin.Forms 2.1.0 Released

TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai
edited November 2016 in Xamarin.Forms

Edit - Hotfix released with fix for AppCompat ActivityIndicator issue

New Features

UWP support

Stable UWP support (excluding maps). UWP support with maps will be stable in Xamarin.Forms 2.2.0.

ControlTemplates

ControlTemplates have been introduced into the 2.1.0 branch, and have been included on the following types:

TemplatedPage and TemplatedView now serve as the base class for ContentPage and ContentView. ControlTemplates can be used to define the visual appearance of a Control or Page while providing a clean separation from the visual hierarchy and the Content itself. ControlTemplates can be applied via Style to greatly expand themeability in Xamarin.Forms.

Along with ControlTemplates the concept of TemplateBindings has been introduced. TemplateBindings work identically to normal Bindings however their Source is automatically set to the parent of the target view which owns the ControlTemplate. Usage of a TemplateBinding outside of a ControlTemplate is not supported.

For more details on how to use ControlTemplates see here: http://xfcomplete.net/general/2016/01/20/control-templates/

DataTemplateSelector

IDataTemplateSelectors allow the selection of a DataTemplate at runtime per item in a ListView.ItemsSource.

Usage:

class MyDataTemplateSelector : DataTemplateSelector
{
    public MyDataTemplateSelector ()
    {
        // Retain instances!
        this.templateOne = new DataTemplate (typeof (ViewA));
        this.templateTwo = new DataTemplate (typeof (ViewB));
    }

    protected override DataTemplate OnSelectTemplate (object item, BindableObject container)
    {
        if (item is double)
            return this.templateOne;
        return this.templateTwo;
    }

    private readonly DataTemplate templateOne;
    private readonly DataTemplate templateTwo;
}
<ListView DataTemplate=local:MyDataTemplateSelector />

DataTemplateSelectors have the following limitations:

  • No more than 20 templates per ListView on Android
  • The DataTemplateSelector subclass MUST always return the same template for the same data if queried multiple times
  • The DataTemplateSelector must not return another DataTemplateSelector
  • The DataTemplateSelector must not return new instances of a DataTemplate on each call, instead the same instance must be returned. Failure to do so will effectively disable virtualization and lead to an enormous memory leak. Don't do this.

For step-by-step instructions on how to add data template selectors to your mobile app, follow this guide from the Xamarin blog.

Effects

Effects provide an easy way to customize the native look and feel of controls without having to resort to a complete Custom Renderer. You can use these to customize the native controls, for example, the following Effect shows how to create a Border effect on iOS that will set a 2 pixel purple outline on the control:

// located inside iOS specific codebase
public class BorderEffect : PlatformEffect
{
    protected override void OnAttached ()
    {
        Control.Layer.BorderColor = UIColor.Purple.CGColor;
        Control.Layer.BorderWidth = 2;
    }

    protected override void OnDetached ()
    {
        Control.Layer.BorderWidth = 0;
    }
}

To apply this effect, all you have to do is attached it via the IList<Effect> Effects collection on Element. This is a much simpler way of fine tuning your user interface with native touches.

Other Improvements

  • HasUnevenRows dynamic sizing support;
  • ListView Virtualization is now supported on Windows ;
  • Generic versions of Create () BindableProperty are no longer supported and deprecated;
  • The Entry/Editor updates on WP8 and WinRT are now consistent with other platforms;

Bug Fixes

  • Bug 21780 - Windows Phone Editor control has black background with black text, background turns to white when editing.
  • Bug 24769 - [Win Phone/winrt] Progress Bar in listview item not working
  • Bug 26868 - GroupHeaders do not extend on Windows Phone and WINRT
  • Bug 30370 - Background Color on an Entry Control is Applied to the Padding
  • Bug 32615 - [Android] OnAppearing is not called on previous page when modal page is popped
  • Bug 32847 - Picker text is cleared after selecting an item, whether Picker, DatePicker, or TimePicker
  • Bug 33268 - Picker is broken on Windows 8.1
  • Bug 33870 - crash when the listview selection is disabled on Windows Phone 8.1 RT
  • Bug 35490 - Label Text Misaligned in Windows Phone 8.1 and WinRT (Xamarin Nuget Version 1.5.1.6471)
  • Bug 35811 - Navigation.PushAsync from TabbedPage then hit back button causes crash
  • Bug 36171 - WinRT Entry UI not updating on TextChanged
  • Bug 36174 - Android Search Bar vertical text alignment in Forms 2.0
  • Bug 36251 - Issues when switching between pages of a TabbedPage on iOS
  • Bug 36422 - XamlC Fails When using X:Array in Xaml. Throws NullReferenceExceptio
  • Bug 36559 - [WP] Navigating to a ContentPage with a Grid inside a TableView affects Entry heights
  • Bug 36649 - LineBreakMode.NoWrap is handled incorrectly on Windows Phone 8.1 RT
  • Bug 36687 - On WinPhone 8.1 RT, the background color used in Entry fields is not as expected
  • Bug 36730 - OnStart / OnResume are not called on WP8.1 and UWP
  • Bug 36778 - ListView on UWP doesn't display Detail line with TextCell
  • Bug 37306 - XamlC doesn´t support adding x:String in resource dictionary
  • Bug 37675 - Style PropertyChanged called before the Style is applied
  • Bug 37779 - TabbedPageRenderer throws exceptions on Android 4.0.4 when using Material Design theme
  • Fixes to OnAppearing/OnDisappearing;
  • Fixes to PanGestureRecognizer on android;
  • Fixes to animation safety;
  • UWP fix headerzoom;
  • Fixes an issue where images sometimes didn't load on WP8
  • Fix compatibility issue with Android API version 15
  • Fix crash when loading remote images that don't exist on Windows
  • Fix crash on Windows with negatively sized views
  • Fix crash when invalidating measure inside of a layout call
  • Fix issue where contents of ScrollView sometimes show up blank on Windows.

Known Issues

  • WinRT reloads toolbar items on navigation even when they haven't changed

Important notes:

«13

Posts

  • JacobPoulsen_JacobPoulsen_ DKMember ✭✭✭

    Nice, great release!

    I have an issue though, where rotating my Ipad/Iphone causes the app to freeze (not crash, just freeze) giving me no help for debugging.

    I have a TabbedPage as the MainPage. Inside the TabbedPage one of the Children is as CarouselPage with about 5 subpages.

    When the CarouselPage is visible (the selected tab in TabbedPage), and i try to rotate the device the app freezes. It happens on both iPad, iPhone and Simulator.

    It also seems like others are having similar issues: https://forums.xamarin.com/discussion/comment/183090#Comment_183090

    Let me know if you need more info.

  • I have created a "dialog" for showing an AcitivtyIndicator.
    Sadly, it doesn't show after the update from 2.0.1 to 2.1.0.

    Here is my class for the dialog.

  • CherubyxCherubyx CAUniversity ✭✭

    Great release! When can we expect Xamarin Forms to use the updated Xamarin.Android libraries version 23.1.1.0?

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    Hm. I would've expected that you make the Effects work for Cells too before you release them.
    See bug #38739.

  • BastiBrauningBastiBrauning USMember ✭✭
    edited March 2016

    Awesome work with the UWP stuff. My LayoutCycle problems seem to be gone. Thanks alot.

  • JohnHJohnH GBMember ✭✭✭✭✭

    @TheRealJasonSmith Hi Jason, any update on the viewcell.ForceUpdateSize() issue?

  • BryanHunterXamBryanHunterXam USXamarin Team Xamurai

    @HansvandenElsen said:
    I have created a "dialog" for showing an AcitivtyIndicator.
    Sadly, it doesn't show after the update from 2.0.1 to 2.1.0.

    Here is my class for the dialog.

    Thanks. We are looking into this one now.

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    @TheRealJasonSmith Any way to get this fixed in the next release? https://bugzilla.xamarin.com/show_bug.cgi?id=38019

    Right now, I can't hide the title bar completely on pages that contain image and video content as well as other types of full screen pages. It's really frustrating. :|

  • hvaughanhvaughan USMember ✭✭✭

    @BryanHunterXam @HansvandenElsen

    Experiencing something similar but using the PopupLayout control from XLabs and instead getting a NullReferenceException.

    It looks like Content gets correctly set in the constructor, but then suddenly becomes null when trying to run the ShowPopup() method and the this.content.InputTransparent = false; line gets hit.

  • SergiuCosminSergiuCosmin USMember ✭✭

    @TiffanyIp said:
    Great release! When can we expect Xamarin Forms to use the updated Xamarin.Android libraries version 23.1.1.0?

    same question from me, I already see some updates are available on some other nuget packages I use but I cannot install them because XF doesn't support the 23.1.1.0 libraries

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @MichaelRumpler it required too big of a change, we will be adding support for that in a very near term point release that can start the -pre cycle again.

  • MaxMengMaxMeng NZMember ✭✭✭

    Any changes relate to ListView.ItemsSource? My custom listview doesn't work in 2.1 anymore.

  • PeterDedenePeterDedene BEMember ✭✭

    On Windows Phone 8.1, I'm having trouble with the combination of RelativeLayout and a scrollable view (ScrollView / CarouselView / ListView) as an indirect child.

    I managed to produce a minimal example that has the problem. If I render this page:

    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 x:Class="App1.Page1">
      <RelativeLayout>
        <AbsoluteLayout BackgroundColor="Red"
                    RelativeLayout.XConstraint="{ConstraintExpression Type=Constant, Constant=0}"
                    RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
            RelativeLayout.YConstraint="{ConstraintExpression Type=Constant, Constant=0}"
            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-40}">
    
          <ScrollView Orientation="Vertical">
            <Label BackgroundColor="Aqua" HorizontalOptions="Fill">
              <Label.Text>
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut vulputate lectus elit. Suspendisse et fringilla lacus. Proin pulvinar varius lacinia. Mauris pulvinar est nulla, vitae faucibus augue sollicitudin eu. Sed vel posuere diam. Donec faucibus ex a dolor bibendum, vitae cursus urna luctus. Morbi ultrices dignissim interdum. Vestibulum ut sem nibh. Morbi faucibus dui id elementum efficitur. Curabitur sollicitudin augue quam, sit amet porta odio accumsan in. Nullam nisl eros, facilisis id felis quis, mollis mattis velit. Ut tempor consequat suscipit. Etiam lectus lacus, placerat eu erat sit amet, iaculis elementum dui. Pellentesque varius, ipsum ac iaculis convallis, ex arcu tempor neque, nec iaculis enim ipsum et nibh. Nam finibus porta ornare. Mauris in nisl et purus venenatis dignissim.
              </Label.Text>
            </Label>
    
          </ScrollView>
    
        </AbsoluteLayout>
    
        <BoxView BackgroundColor="Green"
                        RelativeLayout.XConstraint="{ConstraintExpression Type=Constant, Constant=0}"
                        RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-40}"
                        RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
                        RelativeLayout.HeightConstraint="{ConstraintExpression Type=Constant, Constant=40}"
                        HeightRequest="40"
                 />
      </RelativeLayout>
    </ContentPage>
    

    I get a black screen, i.e. the AbsoluteLayout and BoxView have width and height 0.

    When I make the ScrollView a direct child of the RelativeLayout, it renders fine. When I remove the ScrollView, it renders fine. It renders fine on 2.0.0 and on 2.1.0 on iOS (I didn't try android yet).

    We really want to update to 2.1.0 to take advantage of the ListView virtualization on Windows.

  • hvaughanhvaughan USMember ✭✭✭

    @MaxMeng
    Second item in the post...

    DataTemplateSelector

    IDataTemplateSelectors allow the selection of a DataTemplate at runtime per item in a ListView.ItemsSource.

  • DanBDanB DEMember
    edited March 2016

    The followoing Code is not working anymore on WP 8.1 SL (iOS, Android not tested yet)
    _label.Opacity = 0.0; _label.IsVisible = true; await _label.FadeTo(1, 500); _label.IsVisible = false;
    The last line_ Label.IsVisible = false ->the Label shut disappear again, but this don’t happen on WP.

    With XF 1.4.3.6376 its working as expected, with XF 2.1.0.6524 not.
    I have attached a Repro Project. please have a look and fix it soon.

    Thx.

  • JKayJKay USMember ✭✭✭
    edited March 2016

    Has anyone got any examples / Blog posts on using the Effects? I'm not sure I fully understand them

  • Shane000Shane000 USMember ✭✭✭

    I believe there is one on Jason Smith's blog but no amount of googling or searching through his posts could find it.

  • RogerSchmidlinRogerSchmidlin CHUniversity ✭✭✭

    Once the IsGestureEnabled is set to false, setting it to true again doesn't have any effect on iOS. The gesture stays disabled.

  • JKayJKay USMember ✭✭✭

    @JMarcus Thats great. Thanks!

  • ChristianFalchChristianFalch NODeveloper Group Leader ✭✭✭

    Why was the generic Create version on BindableProperty marked as obsolete? It gives a true type safe and simple way of creating bindable properties.

  • rogiheerogihee NLMember ✭✭✭

    @ChristianFalch : see the pre-thread message from Jason for this version: it apparently creates a ridiculous amount of IL code, hurting app binary size and performance on iOS.

    Non-generic versions are working just fine, I have converted my bindings. Bit of work but not too hard.

  • ChristianFalchChristianFalch NODeveloper Group Leader ✭✭✭

    Ok, thanks @RogiervanderHee - thanks for the info.

  • JohnErikssonJohnEriksson USUniversity ✭✭

    Any one got some example on how to convert the generic BindableProperty.Create<>() to a not generic version?

    I want to be able to bind to an ICommand.

  • ScottDavisScottDavis USMember ✭✭

    @PeterDedene In this update scrollable content will not render in any view that has relative display siblings, StackLayout and Grid (with auto or star) included. If you need to have scrollable content the only way I have gotten it to work is to make sure every parent is a content control or absolute layout.

    Also, for anyone keeping a tally, Windows Phone images still don't display in a ListView, unless they are the only content of the list view cell. This has been an issue for a long time. In a list of 15 items, I saw one image show up once, but not one a second attempt. Must be missing a redraw event or something.

  • JohnErikssonJohnEriksson USUniversity ✭✭

    @hvaughan
    Great, thanks! :-)

  • JohnErikssonJohnEriksson USUniversity ✭✭

    I'm getting an crash on Android when using NavigationPages in a TabbedPage. I'll try to recap what I've found out:

    I did this test on the Xamarin.Forms sample named TabbedPageWithNavigationPage, found on the link below:
    https://github.com/xamarin/xamarin-forms-samples/tree/master/Navigation/TabbedPageWithNavigationPage

    1. I installed Xamarin.Forms v. 2.1.0.6524
    2. I modified the example to use NavigationPages in all three tabs.
    3. Everything workes fine.

    4. I modified the Android project to use Material Design according to the blog post below:
      https://blog.xamarin.com/material-design-for-your-xamarin-forms-android-apps/

    5. When testing I can move to the second tab, but when moving to the third tab the app crashes.
      Java.Lang.IllegalStateException: Recursive entry to executePendingTransactions

    6. I installed Xamarin.Forms v. 2.0.1.6505

    7. It works fine again to move between all three tabs.

    Note: If I try this without using NavigationPages in the tabs, just ContentPages, it works fine ven on Xamarin.Forms v. 2.1.0.6524.

    Any clues?

  • PeterDedenePeterDedene BEMember ✭✭

    @ScottDavis I have no issues with images in a listview, but I'm using FFImageLoading (https://github.com/molinch/FFImageLoading) for most of my images.

  • MarkoLudolphMarkoLudolph DEMember ✭✭

    Hey there,

    I have a problem with UWP. When I put my content into a ScrollView, all the text is blurred, see the screenshots. Blurred layout: ContentPage -> ScrollView -> StackLayout. Not blurred: ContentPage -> StackLayout, but, well, I can't scroll :neutral:

    imageimage

  • Matthew.4307Matthew.4307 USMember ✭✭✭
    edited March 2016

    Windows RT - Navigation bar missing on Master Details Page
    Android - List View View Cells do not resize when when cell content changes size - It's behaving like iOS!

  • LucasCullenLucasCullen AUMember ✭✭

    Did an update via NuGet this morning. Solution won't compile. After about 4 hours of trying to hack packages.config, cleaning, trying to restore specific versions, pulling my hair out... I finally got it compelling by reverting my code in GitHub. Not happy.

  • MichaelDimoudisMichaelDimoudis AUUniversity ✭✭

    I just stumbled in to this issue https://forums.xamarin.com/discussion/comment/183646/#Comment_183646 by @RonaldVerhaegen

    Java.Lang.IllegalStateException: Recursive entry to executePendingTransactions

    Basically 3 or more tabs with NavigationPages in Android totally doesn't work and crashes app.

    I haven't filed a bugzilla report yet (not sure if Ronald has) but I will when I get time later on. I have downgraded to 2.0.1 until this is fixed.

  • MichaelRumplerMichaelRumpler ATMember ✭✭✭✭✭

    My iOS app sometimes crashes when navigating back too fast (by tapping on the back button, not programmatically). Somebody already filed bug #38731 for XF 2.0.1. I get it on XF 2.1.0.

    I have some of these messages in the debug window:

    Unbalanced calls to begin/end appearance transitions for <_UIWaitingForRemoteViewContainerViewController: 0x7e97c1e0>.

    Followed by

    System.NullReferenceException: Object reference not set to an instance of an object
    at Xamarin.Forms.Platform.iOS.NavigationRenderer.GetAppearedOrDisappearedTask (Xamarin.Forms.Page page)

    and

    The app has been terminated.

  • @BryanHunterXam said:

    @HansvandenElsen said:
    I have created a "dialog" for showing an AcitivtyIndicator.
    Sadly, it doesn't show after the update from 2.0.1 to 2.1.0.

    Here is my class for the dialog.

    Thanks. We are looking into this one now.

    How are things going? I see an update the next day regarding the ActivityIndicator, but I still see no difference.

  • @MichaelDimoudis I just submitted a bug report about: Java.Lang.IllegalStateException: Recursive entry to executePendingTransactions.
    https://bugzilla.xamarin.com/show_bug.cgi?id=39403

  • RikardBRikardB USMember
    edited March 2016

    Since updating to forms 2.1.0 my listviews doesn't render on windows silverlight 8.1 if the list is bigger then the screen. The following pseudo layout doesn't work:

        <listview>
            <stacklayout>
                <grid>
                    <label></label>
                </grid>
            </stacklayout>
        </listview>
    

    It also doesn't work if I remove the grid or the stacklayout. But if I remove both then the screen renders. All functionality works but the screen doesn't render and this only happens on silverlight 8.1.
    Does any know any workaround for this?

  • NightOwlNightOwl USMember ✭✭

    @hvaughan said:
    @BryanHunterXam @HansvandenElsen

    Experiencing something similar but using the PopupLayout control from XLabs and instead getting a NullReferenceException.

    It looks like Content gets correctly set in the constructor, but then suddenly becomes null when trying to run the ShowPopup() method and the this.content.InputTransparent = false; line gets hit.

    I've exactly the same issue, which is making the update possible for our app.
    Did you solve it?

  • hvaughanhvaughan USMember ✭✭✭

    @NightOwl
    I did not solve it but I also have not attempted to solve it either. You might check the XLabs' GitHub Issue queue to see if anyone has reported it yet and/or report it yourself. I currently have not had time to look into it and just downgraded to solve the issue. Please let me know if you make any progress!

  • MarkoLudolphMarkoLudolph DEMember ✭✭

    I added a bug report for the blurred text in UWP https://bugzilla.xamarin.com/show_bug.cgi?id=39461. And here's a sample Screenshot, that shows the problem. As soon as a Label is inside of a ScrollView, the text is blurred. That's the last bug, that prevents the release of the desktop version of my app, while the mobile version is already in the store.

    image

Sign In or Register to comment.