Same as -pre2 with an additional bug fix for Android ContextActions.
This is a feature release. As such unlike a patch version bump, the minor version bump indicates the inclusion of new APIs.
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.
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/FooterListView
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.
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 ()
On Android OpenGLRenderer
has been renamed OpenGLViewRenderer
for consistency.
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.
{}foo
Posts
I am glad to see Xamarin.Forms is growing, pulltorefresh.., when can we see professinal Tabpage, slidingpage and visiable design?
Nice one Jason - great work as always!
Awesome
Might be something on my machine but when I try to compile the Android part of a Xamarin.Forms project and Static Link the SDK I get this:
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item 'System.Void Android.Widget.AbsListView::SetSelectionFromTop(System.Int32,System.Int32)' (defined in 'Xamarin.Forms.Platform.Android, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null') from 'Xamarin.Forms.Platform.Android, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.Widget.AbsListView::SetSelectionFromTop(System.Int32,System.Int32)
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue()
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Mono.Linker.Steps.MarkStep.Process()
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Mono.Linker.Pipeline.Process(LinkContext context)
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute()
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: --- End of inner exception stack trace ---
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Xamarin.Android.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute()
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
13>C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1017,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext()
Awesome. I love ListView feature updates. However, I could see one breaking issue on the ListView. I used to set (sender as ListView).SelectedItem=null to avoid selection color in the listview. But, now it breaks. Always first item getting selected background(some blue color) even If I set null in the event. Also first Item always getting selected background color even if I select other items. Anything wrong?. Any new property available to avoid selection background?
I think there is an issue (probably introduced in a previous version) with HasUnevenRows being set to true on IOS (at least).
The ItemAppearing event fires for all items in the list even if they haven't appeared (presumably because they're loaded in order to measure them)
The problem is though that this breaks my infinite scrolling which I think is the main usecase for the ItemAppearing event.
Please let me know if you can't reproduce this because there's always a chance the situation is more complicated that I have described in which case I'll try to find out why I am seeing this behaviour
@Mihai Cvasnievschi : I am also facing same issue.
I'm also noticing the same issue as @MartinBooth (Also on IOS)
How do you perform a pull to refresh using the Windows Phone emulator? I've tried the swipe down motion that works in iOS and Android, but it does not seem to work for WinPhone. I'm not all that familiar with WinPhone gestures, so I am sure that is the issue. The new pull to refresh works great in iOS and Android!! Nice addition.
Updated to 1.4.0 and started getting a crash w/ relativelayout in the xaml. Haven't touched that file and it worked fine before
Just blogged on the pull to refresh goodness: http://motzcod.es/post/113280718807/official-pull-to-refresh-in-xamarin-forms-1-4-0
WP is the same, a pull down to refresh
I am seeing that pull to refresh on WP only seems to work when there are more rows than can fit on one screen. If, for example, there are only two items in the list view, pulling down on the list does not seem to work. I have tried setting the list views layout options (horizontal and vertical) to FillAndExpand. Also tried as the only control on the page and inside a StackLayout. Is this a bug, or am I missing something?
Thanks
@ShanePope this is a known issue if you have your code set to break on a XamlParseException. You should be able to continue and it will work as expected. I was able to upgrade to 1.4.0 and load a RelativeLayout Xaml with ConstraintExpressionExtension just fine (but with lots of messages in the debugger).
My guess is that you at some point set your debugger to break on XamlParseException and that is why you are seeing the error now. I could be wrong, though.
Here's the bug: https://bugzilla.xamarin.com/show_bug.cgi?id=27730
@MikeEEE thanks, Something else was crashing and I just managed to hit that first when I turned on all exceptions.
The actual crash is that my converter stopped working:
<Label Text="{Binding DateOfBirth, Converter={StaticResource DOBLabelConverter}}"/>
It was fine before, I assume it has something to do with the 1.4.0 xaml / static changes?I am defining and referencing the converter inside the resource dictionary. Could that be a problem? It worked in 1.3.5
<ResourceDictionary> <converters:DOBLabelConverter x:Key="DOBLabelConverter"/> ......
@PeteGiles.2978
I have filed a bug (27845) for this issue. I will take a look to see whether I can come up with a workaround this evening
@ShanePope ... hmm... not sure. I would have to see the entire Xaml to be sure. Are they in the same file? I of course prefer using singleton instances for my converters... saves a lot of work and you're not having to chase down ResourceDictionary entries half the time. You might want to try that to see if it fixes your problem. Here's an example of setting one up:
https://github.com/Michael-DST/xamarin-forms-samples/blob/master/FormsGallery/FormsGallery/FormsGallery/Support/LuminosityConverter.cs#L9
Usage in Xaml:
https://github.com/Michael-DST/xamarin-forms-samples/blob/master/FormsGallery/FormsGallery/FormsGallery/AbsoluteLayoutDemoPage.xaml#L9
Thanks @MikeEEE, referencing like that fixed it. So 1.4.0 introduced a bug where if you define a converter in your xaml resource dictionary, and then reference it below (in my case a viewcell datatemplate). It can't find the converter.
Filed here: https://bugzilla.xamarin.com/show_bug.cgi?id=27863
System.Exception: Position 35:36. StaticResource not found for key DOBLabelConverter
at Xamarin.Forms.Xaml.StaticResourceExtension.ProvideValue (IServiceProvider serviceProvider) [0x00000] in :0
at Xamarin.Forms.Xaml.ApplyPropertiesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.RootNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00000] in :0
at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.String xaml) [0x00000] in :0
at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x00000] in :0
at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[ComposeMessagePage] (Company.Mobile.Pages.ComposeMessagePage view, System.Type callingType) [0x00000] in :0
at Company.Mobile.Pages.ComposeMessagePage.InitializeComponent () [0x0000c] in /Users/shane/GitHub/Company.Mobile/Company.Mobile/obj/Debug/ComposeMessagePage.xaml.g.cs:44
[clipped]
BindingContext of Footer in Listview is null from xaml:
Does not work, because BindingContext in the label is null (but the page has one). Is this a bug and is there a way in xaml to set it to the parent's view? Like BindingContext="{Binding ParentView.BindingContext}" (does not work) - without using code-behind file
@ShanePope: Weird, that's good to know. That should still resolve since it's in the logical hierarchy. Is this code somewhere where I could try to help verify and possibly submit a bug if so?
@MikeEEE I tried to write a sample app to reproduce it that I could share but it didn't crash. Definitely was a 1.4.0 regression but I can't spend more time looking into why right now. Thanks again for the workaround.
Even worse, in the above code, if I set the BindingContext in the code-behind file, the footer does not get resized when IsVisible of the label changes (Android). The place/height of the label is always there at the end of the list. So how is this supposed to be used? Is this only a "static" footer which should not be changed after initialized?
Tried to set footer after the loading operation to null, but for that I get an exception:
[MonoDroid] UNHANDLED EXCEPTION:
[MonoDroid] System.NullReferenceException: Object reference not set to an instance of an object
[MonoDroid] at Xamarin.Forms.Platform.Android.ListViewRenderer/Container.OnMeasure (int,int)
[MonoDroid] at Android.Views.View.n_OnMeasure_II (intptr,intptr,int,int) [0x00009] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.21-series/49a04b96/source/monodroid/src/Mono.Android/platforms/android-16/src/generated/Android.Views.View.cs:12274
[MonoDroid] at (wrapper dynamic-method) object.4f5eb468-bce0-4fbe-8865-c7a37e82f01b (intptr,intptr,int,int)
@TheRealJasonSmith .. I have a page with a lot of fields (and therefore requiring a scrollview) where all fields are disabled .. then on WP you cannot scroll. It Works fine on both Android an iPhone.
And this used to work fine in previous version of XF.
Is that a known issue?
Also .. I'm still not able to disable an Editor control on iOS. Yes .. in a ScrollView. :-)
/per
Not sure if it's something within my project by I'm trying to use ListView's ScrollTo to scroll to the top of the list and any attempts I had at getting it working failed.
This is the exception I get:
"Argument is out of a range.\n Parameter name: index"
Stack trace:
0x21 in System.Diagnostics.Debugger.Mono_UnhandledException_internal C#
0x1 in System.Diagnostics.Debugger.Mono_UnhandledException C#
0x3E in object.6dde6d35-951e-47b4-b4fb-d994267d69e1 C#
0x15 in Xamarin.Forms.ListProxy.get_Item C#
0x9 in Xamarin.Forms.TemplatedItemsList<Xamarin.Forms.ItemsView<Xamarin.Forms.Cell>,Xamarin.Forms.Cell>.get_Item C#
0xB1 in Xamarin.Forms.Platform.Android.ListViewRenderer.OnScrollToRequested C#
0x1D in Xamarin.Forms.Platform.Android.ListViewRenderer.OnLayout C#
0x12 in Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII C#
Current code:
Device.BeginInvokeOnMainThread(() =>
{
try
{
list.ScrollTo(null, ScrollToPosition.Start, false);
}
catch { }
});
Called from OnAppearing ...
Please note I've also tried by passing the first item with same result. Anywaym, I would expect ScrollTo position to work without passing an item if one wants to scroll to beginning of list.
@MihaiCvasnievschi
I am not sure if it is the same issue but I was getting a similar exception to what you noted: "Argument is out of a range.\n Parameter name: index" when I had bound a generic List to the ListView instead of an ObservableCollection. I would get the exception when I tried the new Pull-To-Refresh feature built into the ListView. I fixed it by using an ObservableCollection instead of a List.
Dan
Does anyone have a sample for a listview with footer. I don't know how to set the footer
I made a few test and in this way it doesn't work
var listView = new ListView {
Footer = new TextCell {
Text = "Halt"
},
FooterTemplate = new DataTemplate(typeof(TextCell))
};
@TheRealJasonSmith
I've already written in a thread for a new bug. Take a look at this: http://forums.xamarin.com/discussion/35906/tabbedpage-nullpointerexception
I filled in a new bug here with an example app here: https://bugzilla.xamarin.com/show_bug.cgi?id=28191
@TheRealJasonSmith I am using the latest stable versions. I have a listview that opens another page whenever a list item is tapped. I am getting the error below. Sometimes it happens immediately on the first item tap, other times I would have to tap a few items before I get the error. It causes the app to crash.
Upgrading to Xamarin Forms 1.4.0.6341 causes a Null Reference exception to be thrown in an Android Custom CellRenderer.
Steps to reproduce
as comparison if you checkout the master branch : https://github.com/paulpatarinski/Xamarin.Forms.Plugins/tree/master/ExtendedCells
which is running Forms 1.3.2.6316 the exception does not occur.
Stack Trace attached
Hi,
I love all the new features. They make my life a lot easier. But I still miss a lot of styling options for the most basic controls. With forms I cannot style my app completely like the way I would on a native platform. I now do this with renderers but it takes up a lot of my time I would like to spend on app features instead of styling.
FooterTemplate cause NullReferenceException when StackLayout is put inside it. HeaderTemplate works fine in same conditions. I started a thread about this here
This is definitely a version 1.x product @BrunoVanThournout.9700 ... if you're in it now, you're in it for the long run.
To me, it's like going through Silverlight all over again (but on a much bigger and viable scale). There was a lot of churn with Silverlight and it really didn't start getting awesome until 4.0. 5.0 was really quite supreme and you could make a living off it (if it wasn't for those darned devices and Apple...).
I think Xamarin is more efficient than MSFT, however.
In another year or so this tech is going to be UBER-supreme haha.
@TheRealJasonSmith - found an interesting issue on iOS.
Run the MobileCRM Sample on iOS while the Personal Hotspot has at least one connection (it would show under the iOS status bar).
Forms do not properly resize the screen to show the Tab buttons (they got cut). This only happens when starting the app, if sent to background and reactivated the UI will be correctly displayed.
Edit 1: I've tested on another app that we've developed and that uses Tabs and the issue can-not be reproduced. I think you could test this out whenever you have 5 minutes ;-) Not a show stopper!
Footer is not shown on iOS.
Footer height is not always calculated correctly on Android.
@MihaiCvasnievschi were you able to get past through your linker error.I am getting same exception with 1.3.2 version of xamarin forms.
@TheRealJasonSmith I'm having the same issue @WesselOosthuizen reported earlier in the thread. I have a ListView that opens another page when clicked. This ListView occasionally (rarely, seemingly randomly) throws an error that crashes the app when clicked. This issue only happens on the Android build.
@TheRealJasonSmith I'm having the same issue @WesselOosthuizen reported earlier in the thread. I have a ListView that opens another page when clicked. This ListView occasionally (rarely, seemingly randomly) throws an error that crashes the app when clicked. This issue only happens on the Android build.
I've just upgraded to this release to get the fix for bug 25611, but seem to have hit another one on WinPhone.
If I have 52 items in a ListView, and I use the following code to scroll to the end:
This works fine on Android and iOS, but on WinPhone it only scrolls part way down the list- down to the 42nd item.
I can't see this raised as a bug already.
Did anyone encounter listview rendering issue where it sometimes doesn't display the content in cell and if the listview content is long enough for the cell that has display issue to scroll off screen and come back...the content will then display properly?
@monkichi:
Yes I also had this (on iOS), but not really to comprehend.
@TheRealJasonSmith I can confirm that ListView.ScrollTo works as long as the ListView is bind to an ObservableCollection but this degrades the performances of the initial load for long lists.
Are there any plans to allow the ListView to ScrollTo Start or End without having to provide a specific item? It's not like I want to scroll to a particular item I just want to make sure that the list is at its start.