Xamarin.Forms 4.0.0 Early Preview

Getting Started | What's New | Known Issues | Blogs | Feedback | Open Source

What's New in this Release

Xamarin.Forms 4.0.0-pre1 is a substantial release with several big new features. As such, we are releasing much earlier than usual to get more feedback not only on the quality of the release, but on the use of the features while we are still developing them.

While we work on 4.0.0, we will continue releasing quality improvements and minor enhancements via the 3.x series approximately every 6 weeks.

To get started with Xamarin.Forms 4.0 enable all the new features in your MainActivity.cs and AppDelegate.cs via the feature flags api:

global::Xamarin.Forms.Forms.SetFlags("Shell_Experimental", "Visual_Experimental", "CollectionView_Experimental");
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

Here's what you have to look forward to:

Shell

Shell introduces a simplified way to express the structure and navigation for your application in a single file. No more dealing with different page types to handle setting up complicated navigation. It supports flyout menu, bottom tabs, top tabs, and an integrated search handler. A new URI based navigation routing system has been implemented in addition to the existing push/pop navigation service. Now you can route to any point in your application, no matter how deep, and handle navigation events to perform custom logic such as canceling the back action.

To get started, add a new ContentPage with XAML to your project and modify the code below to match your namespace:

<?xml version="1.0" encoding="UTF-8"?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms" 
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
       xmlns:local="clr-namespace:NewApp"
       RouteHost="companyname.com"
       RouteScheme="app"
       Route="NewApp"
       FlyoutBehavior="Disabled"
       Title="NewApp"
       x:Class="NewApp.AppShell">

    <!-- 
        Styles and Resources 
    -->
    <Shell.Resources>
        <ResourceDictionary>
            <Color x:Key="NavigationPrimary">#2196F3</Color>
            <Style x:Key="BaseStyle" TargetType="Element">
                <Setter Property="Shell.ShellBackgroundColor" Value="{StaticResource NavigationPrimary}" />
                <Setter Property="Shell.ShellForegroundColor" Value="White" />
                <Setter Property="Shell.ShellTitleColor" Value="White" />
                <Setter Property="Shell.ShellDisabledColor" Value="#B4FFFFFF" />
                <Setter Property="Shell.ShellUnselectedColor" Value="#95FFFFFF" />
                <Setter Property="Shell.ShellTabBarBackgroundColor" Value="{StaticResource NavigationPrimary}" />
                <Setter Property="Shell.ShellTabBarForegroundColor" Value="White"/>
                <Setter Property="Shell.ShellTabBarUnselectedColor" Value="#95FFFFFF"/>
                <Setter Property="Shell.ShellTabBarTitleColor" Value="White"/>
            </Style>
            <Style TargetType="ShellItem" BasedOn="{StaticResource BaseStyle}" />
        </ResourceDictionary>
    </Shell.Resources>

    <!-- Your Pages -->
    <ShellItem>
        <ShellContent>
            <local:MainPage/>
        </ShellContent>
    </ShellItem>

</Shell>

Then set this AppShell class as your main page in the App.xaml.cs file:

namespace NewApp
{
    public partial class App : Application
    {
        public App ()
        {
            InitializeComponent();

            MainPage = new AppShell();
        }
    }
}

For more information about Shell check out the preview doc and view the Tailwind Traders mobile reference app. If you're evaluating Visual Studio 2019 on Windows, we've created a set of Shell templates for you. Download and install the package here.

Visual

Visual is a new way to achieve consistent UI design across iOS and Android, beginning with an implementation of Google's Material Design. This first iteration include Button, Entry, Frame, and ProgressBar. Visual goes beyond styles to also unify behavior and when necessary providing highly customize renderers.

Xamarin.Forms Visual on Android and iOS

For more information about Visual, check out the preview doc.

CollectionView and CarouselView

CollectionView is the flexible and performant list control that you've been asking for. It can handle horizontal, vertical, and grid layouts out of the box, and you can provide custom layouts as well. CollectionView is also the foundation for CarouselView.

For more information about CollectionView, check out the preview doc.

And much more!

  • " Implemented colored refresh indicator for ListView pull-to-refresh" (#2961)
  • "[Enhancement] Add CollectionView progress behind feature flag" (#4265)
  • "[Enhancement] Add Visual progress behind feature flag " (#4449)
  • "[GTK] Do not show a label in gtk slider renderer" (#4098)
  • "[GTK] Fix synchronization context fairness" (#4237)
  • "[Tizen] Fix Window alpha update timing" (#4119)
  • "[Xaml] Support correctly custom resource providers" (#4236)
  • "[XamlC] Resolve parameters in nested generics" (#4061)
  • "Implementation of method ForceUpdateSize for Cell on macOS" (#4104)
  • "Move GetNativeSize to PlatformServices, remove IPlatform" (#4235)
  • "Remove unnecessary ToArray to reduce number of BindableObject[] allocations" (#4101)
  • Github #1718 - "[Enhancement] Bindable Repeater control" (#4052)
  • Github #1724 - "[Enhancement] ImageButton on Tizen" (#4436)
  • Github #1788 - "[Enhancement] Seal public attributes " (#4559)
  • Github #2057 - "[UWP] Enable dynamic overflow on ToolbarItems" (#4022)
  • Github #2415 - "Xamarin.Forms.Shell Spec" (#4522)
  • Github #2691 - "Make XmlnsDefinitionAttribute Public" (#2782)
  • Github #2910 - "[Enhancement] Ability to set TextColor on TableSection" (#4379)
  • Github #3555 - "[Enhancement] Editor: Control over text-prediction " (#4023)
  • Github #3843 - "[Enhancement] Hide Scroll Bars on ListView" (#3897)
  • Github #3988 - "[UWP] Expose platform specific to set IsDynamicOverflowEnabled on the CommandBar" (#4022)
  • Github #4027 - "Adding OnColor property for SwitchCell" (#4036)
  • Github #4083 - "[Enhancement] remove sealed from Span" (#4331)
  • Github #4470 - "ImageButton and CSS" (#4482)

Known Issues

To track known issues as we work through these new features, check GitHub.

Notable Changes

Release History

  • Monday, December 3, 2018 - Xamarin.Forms 4.0.0.8055-pre1 (4.0.0 Pre Release 1)

Monday, December 3, 2018 - Xamarin.Forms 4.0.0.8055-pre1 (4.0.0 Pre Release 1)

Issues Fixed

  • Github #1399 - "ActivityIndicator width is autosize in absolutelayout is -1/0 on windows" (#3224)
  • Github #1480 - "[iOS] WebTryThreadLock error on WebView with TranslateTo" (#4160)
  • Github #1742/Bugzilla 52656 - "[Enhancement] ToolbarItem A11y" (#3974)
  • Github #2223 - "Entry's IsPassword property , when changed programmatically is not masking/unmasking text in the screen in Mac app " (#4175)
  • Github #2315 - "[Android] Changing from Portrait to Landspace while the calendar is open causes MinimumDate and MaximumDate to be visually ignored" (#4190)
  • Github #2322 - "[MacOS] Image from file not getting searched in the bundle" (#4247)
  • Github #2580 - "Adding accessibility tags to a label seems to cause the renderer to need more space " (#4433)
  • Github #2642 - "ControlTemplate sizing issue in WPF" (#2656)
  • Github #2752 - "[Binding] defaultValueCreator ignored Binding to an unresolved path" (#4541)
  • Github #2831 - "[IOS] label not rendering in BOLD when using a STYLE, Droid however works" (#4111)
  • Github #2881 - "[macOS] ContextActions on ListView not working" (#4243)
  • Github #2951 - "CarouselPage child pages don't fire OnAppearing after update to XF 3.0" (#4475)
  • Github #2952 - "[iOS] WebView not render/update HTML source after second call" (#4468)
  • Github #3208 - "Accessibility Name or HelpText properties added to Switch are visible in Android UI" (#4094)
  • Github #3331 - "[UWP] DatePicker allows a date to be selected which violates the MinimumDate property" (#3683)
  • Github #3385 - "[iOS] Entry's TextChanged event is fired on Unfocus even when no text changed" (#3433)
  • Github #3563 - "[Android] Platform.GetRenderer NullReferenceException" (#4567)
  • Github #3622 - "Android TalkBack reads elements behind modal pages" (#4401) (#4404)
  • Github #3715 - "[Feedback] Xamarin UWP ListView not calling ToString()" (#4016) (#4445)
  • Github #3795 - "[Android/iOS] MasterDetail back button accessibility" (#3974)
  • Github #3930 - "[iOS] Rapidly clicking span on UI test 3525 throws a null exception on simulators" (#4109)
  • Github #3953 - "Java.Lang.NoSuchMethodError: no method with name='getLabelFor' signature='()I' in class Landroid/widget/TextView;" (#3996)
  • Github #3979 - "UWP: InvalidCastException on a Span with a style set via a dynamic resource" (#4024)
  • Github #3994 - "Binding does not update view when BindingContext is page itself" (#4028)
  • Github #4018 - "[Android] Entry resets FontFamily to default" (#4019)
  • Github #4026 - "Bindable Span height Issue" (#4448)
  • Github #4030 - "[macOS] Unhandled exception when switching pages: System.InvalidOperationException: Stack empty." (#4242)
  • Github #4040 - "Label TextColor is not Change When using FormattedString" (#4043)
  • Github #4053 - "AutomationProperties.Name on Button is visible on Android" (#4094)
  • Github #4093 - "When changing IsPassword property of an entry in runtime into true, the keyboard setting of entry is changed from numeric to default" (#4181)
  • Github #4103 - "TargetNullValue does not work with x:DataType" (#4490)
  • Github #4107 - "[Android] WebView breaks previewer on Android" (#4428)
  • Github #4116 - "[UWP] If a control rendered by ViewToRendererConverter is off the screen it causes UWP to crash" (#4532)
  • Github #4130 - "EventHandler Signature Error in 3.3.0 " (#4134)
  • Github #4194 - "SearchBar changes color if initial state is invisible" (#4229)
  • Github #4253 - "Javascript alert dialogs don't work when using WKWebView" (#4254)
  • Github #4262 - "Label HorizontalTextAlignment="Center" not working in conjunction with LineHeight on iOS " (#4275)
  • Github #4295 - "Label Underline TextDecoration disappears after text change" (#4322)
  • Github #4303 - "[Android] TabbedPage's child is appearing before it should be" (#4309)
  • Github #4314 - "When ListView items is removed and it is empty, Xamarin Forms crash" (#4324)
  • Github #4319 - "OnPlatform/OnIdiom markup extension not working using NamedSize" (#4500)
  • Github #4351 - "Previewer broken with latest Xamarin.Forms master builds" (#4355)
  • Github #4360 - "UWP: TapGestureRecognizer works on Layout only if BackgroundColor is set" (#4508)
  • Github #4366 - "[CollectionView] Failure to set ItemsSource causes an unhandled exception to occur" (#4536)
  • Github #4381 - "[iOS] crash on reused page with ScrollView" (#4489)
  • Github #4438 - "Compiled Bindings: Compilation Error - Object reference not set to an instance of an object" (#4483)
  • Github #4446 - "Unhandled Exception with boolean binding when ConverterParameter set instead of Converter" (#4453)
  • Github #4458 - "[UWP] Label MaxLines doesn't work" (#4528)
  • Github #4463 - "uwp's width of Control in titleview not auto change" (#4532)
  • Github #4474 - "[iOS] Number of items not updating with Collection View Control Gallery tests" (#4535)
  • Github #4484 - "[Android] ImageButton inside NavigationView.TitleView throw exception during device rotation." (#4507)
  • Github #4516 - "Binding to an empty collection with indexing throws unhandled exception" (#4525)
  • Github #4596 - "[Shell] queryParams in navigation not handled" (#4615)
  • Github #4603 - "[Shell] Shell push/pop Navigation broken" (#4604)

Additional fixes included in this release

  • "[Android] add Element and Element Property Changed hooks for ImageButton" (#4495)
  • "[Android] fix tabs from element with a tabstop false" (#4362)
  • "[Core] Fix check for CollectionView flag" (#4471)
  • "[Core] perf fixes on BindingExpression.TryConvert" (#4443)
  • "[GTK] Add support for ClickGestureRecognizer" (#3971)
  • "[GTK] Fix several memory leaks in the GTK backend" (#4112)
  • "[Shell] allow missing trailing slash on uri" (#4595)
  • "[Tizen] Fix PropagateEvent value properly on Cells" (#4191)
  • "[Tizen] Fix ToolbarItem" (#4416)
  • "[Xaml] Add provided value to collection" (#4456)
  • "[XamlC] Explicitly cast values for ldc.i4" (#4301)
  • "[XamlC] Port #1035 to compiled bindings" (#4454)
  • "Fix edge case in unsubscribing weak events" (#4538)
  • "Navigation Page double Popped event Workaround" (#3851)
  • "Set ImageButton property of Android.ImageButtonRenderer public" (#4534)
  • "WPF - Map - Fix initial load of pins" (#4304)

Breaking Changes

API Changes

  • " Implemented colored refresh indicator for ListView pull-to-refresh" (#2961)
  • "[Enhancement] Add CollectionView progress behind feature flag" (#4265)
  • "[Enhancement] Add Visual progress behind feature flag " (#4449)
  • "[XamlC] Resolve parameters in nested generics" (#4061)
  • "Navigation Page double Popped event Workaround" (#3851)
  • "Remove unnecessary ToArray to reduce number of BindableObject[] allocations" (#4101)
  • Github #2415 - "Xamarin.Forms.Shell Spec" (#4522)
  • Github #1718 - "[Enhancement] Bindable Repeater control" (#4052)
  • Github #1788 - "[Enhancement] Seal public attributes " (#4559)
  • Github #2057 - "[UWP] Enable dynamic overflow on ToolbarItems" (#4022)
  • Github #2691 - "Make XmlnsDefinitionAttribute Public" (#2782)
  • Github #3555 - "[Enhancement] Editor: Control over text-prediction " (#4023)
  • Github #3715 - "[Feedback] Xamarin UWP ListView not calling ToString()" (#4016) (#4445)
  • Github #3843 - "[Enhancement] Hide Scroll Bars on ListView" (#3897)
  • Github #3988 - "[UWP] Expose platform specific to set IsDynamicOverflowEnabled on the CommandBar" (#4022)
  • Github #4027 - "Adding OnColor property for SwitchCell" (#4036)

Feedback

Your feedback is important to us. If there are any problems with this release, check the Xamarin.Forms Forums, Xamarin.Forms Bugzilla Tracker and GitHub for existing issues. Report new issues and suggestions on GitHub.

Open Source

Xamarin.Forms 4.0.0 is based on the open-source Xamarin.Forms repository: