Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Xamarin.Forms 1.4.0 Released

$
0
0

Same as -pre2 with an additional bug fix for Android ContextActions.

Important Notes

This is a feature release. As such unlike a patch version bump, the minor version bump indicates the inclusion of new APIs.

New API

ScrollView

It is now possible to detect the current scroll offset of the ScrollView. These are readonly bindable properties.

public double ScrollX { get; }
public double ScrollY { get; }

There are also methods which can be used to perform scrolling in the ScrollView.

public Task ScrollToAsync (double x, double y, bool animated);
public Task ScrollToAsync (Element element, bool animated);

The Element passed to ScrollToAsync must be a descendant of the ScrollView but does not have to be a direct child.

Finally for those who do not wish to use bindings to observe scrolling, there is a Scrolled event that fires when ScrollX or ScrollY are updated.

public event EventHandler<ScrolledEventArgs> Scrolled;

public class ScrolledEventArgs : EventArgs
{
    public double ScrollX { get; } = 0;
    public double ScrollY { get; } = 0;
}

Lastly ScrollView no longer uses any internal API to communicate between the frontend and the renderer. IScrollViewController, which is implemented explicitly on ScrollView can be used to trigger these and other events.

ListView

Separator Enhancements
It is now possible to enable/disable separators for the ListView. This can be configured via the SeparatorVisibility property, which is bindable.

public SeparatorVisibility SeparatorVisibility { get; set; } = SeparatorVisibility.Default;

public enum SeparatorVisibility {
    Default = 0,
    None = 1,
}

Currently there is no option for Always as not all platforms have separators as part of their UX. We are considering adding this in the future, however it would be an invented paradigm for Windows platforms.

It is now possible to apply a Color to the separator in ListView.

public Color SeparatorColor { get; set; } = Color.Default;

The default value is Color.Default and will function unchanged from the 1.3.0 implementation if left untouched. RGBA values are supported. This function does nothing in SeparatorVisibility is set to None. Please note that setting either of these properties on Android after loading the ListView incurs a large performance penalty.

Header/Footer
ListView has also grown both a Header and a Footer. These are managed through a series of properties which enable everything from simple usage to more complex MVVM style usage. With Header/Footer the primary reason developers have in the past been forced to put ListViews inside of ScrollViews is finally dead! If you are still placing a ListView inside a ScrollView we strongly suggest you consider porting.

public object Header { get; set; } = null;
public DataTemplate HeaderTemplate { get; set; } = null;
public object Footer { get; set; } = null;
public DataTemplate FooterTemplate { get; set; } = null;

It is important to note that Header or Footer may be set directly to a View and the Template properties left null. This will cause the Header/Footer to be directly consumed by the renderer. All of these properties are bindable.

Pull To Refresh
PullToRefresh has been enabled on all current target platforms for ListView. To enable PullToRefresh in your app simple set IsPullToRefreshEnabled to true and make sure you respond to the correct events. It is important to note that this is the "easy" version of this API, in the future a more complete API with a standalone View may be added.

public event EventHandler Refreshing;

public bool IsPullToRefreshEnabled { get; set; } = false;
public bool IsRefreshing { get; set; } = false;
public ICommand RefreshCommand { get; set; } = null;

public void BeginRefresh ();
public void EndRefresh ();

When the user triggers a PullToRefresh the Command will be invoked and the Refreshed event emitted. IsRefreshing will be set to true. The ICommand.CanExecute property is respected. The user must either call EndRefresh or assign IsRefreshing to false in order to end the refresh state.

All control parameters for these features and more are exposed through the IListViewController interface, which is explicitly implemented on ListView. This will assist those wishing to modify how these features work in custom renderers.

The Windows Phone implementation of PullToRefresh is a custom implementation as there is no platform idiom for doing this. In the future if the Windows platform decided to add a method of doing PullToRefresh by default, we intend to port.

Forms.Application

The Application class now exposes 4 new events for dealing with Modal navigation.

public event EventHandler<ModalPushedEventArgs> ModalPushed;
public event EventHandler<ModalPoppedEventArgs> ModalPopped;
public event EventHandler<ModalPushingEventArgs> ModalPushing;
public event EventHandler<ModalPoppingEventArgs> ModalPopping;

The ModalPoppingEventArgs contains a Cancel property which if set to true will cancel the Pop event and cause the application to enter the background (the operating system is informed of the unhandled back event).

In order to implement this feature, all pre-Application methods of creating a Forms app have been updated to create a default Application which is set as the root pages Parent. It is possible this may cause issues in some edge cases, if you have any issues please file a bug report. It is suggested you update your app to the new LoadApplication initialization methodology if possible.

Application now has a method of manually forcing the Properties dictionary to be saved to the IsolatedFileStore. This is to allow users to save their properties when it makes sense for them rather than risk them not getting serialized out due to a crash/being killed by the OS.

public Task SavePropertiesAsync ()

OpenGLRenderer

On Android OpenGLRenderer has been renamed OpenGLViewRenderer for consistency.

Layout

Layout now contains a ILayoutController class which has an IReadOnlyList<Element> which can be used to enumerate the children of a Layout regardless of the type of the Layout.

Other Features

  • WebView now correctly supports javascript out of the box on Windows Phone 8.0

Bug Fixes

  • Bug 27063 - Navigation not always returning to the proper page.
  • Bug 27225 - Secondary ToolbarItems cause app to hang during PushAsync
  • Bug 27437 - [iOS] Context menu error after deleting an item from a ListView using ContextActions
  • Bug 27096 - EntryCell has different fontsize on Android
  • Bug 21317 - Stepper control .IsEnabled doesn't work on Android
  • Bug 26338 - Unable to change page BackgroundImage from code
  • Bug 26588 - [WinPhone] Entry does not trigger numeric keyboard when password masking is enabled
  • Bug 27072 - Listview Context Actions not removed if a different item is tapped in Android

Other Fixes

  • Stepper default values now can be correctly inherited through a style.
  • x:Static now correctly reports position on error in XAML.
  • XAML now throws a more user friendly error on duplicate x:Name
  • XAML will now use implicit operators when assigning values to properties
  • XAML now supports baseclass indication for collection properties
  • XAML string literals are now supported with {}foo
  • iOS6 Modal pages should no longer sometimes have a 20px offset for no reason

Viewing all articles
Browse latest Browse all 58056

Trending Articles