Xamarin.Forms 2.1.0-pre5 Released

BryanHunterXamBryanHunterXam USXamarin Team Xamurai
edited February 2016 in Xamarin.Forms Releases

Pre-5 Notes

Bug Fixes

  • [Android] Fix crash when swapping main page
  • [WinRT] Fix case where page could show up blank after a pop command
  • [WinRT] NavigationBar properly respects dark theme
  • [WinRT] Reduce instances of LayoutCycle detected
  • [WP8] Password box no longer reveals password when disabled
  • [iOS] Fix crash when PopAsync is called immediately after PushModal
  • [UWP] Fix MasterDetailPage button color issue on UWP

(on Nuget)

Pre-4 Notes

Enhancements

  • Add Effect.ResolveId

Bug Fixes

  • Fix crash in WinRT ListView
  • Fix layout issue in WinRT
  • Fix issue where SearchBar.Text didn't always update correctly
  • Clean up navigation bar in WinRT
  • Fix some crashes when navigating in all platforms

Pre-3 Notes

  • Fix issue where InputTransparent wasn't working correctly in iOS in some cases
  • Fix some cases of Layout Cycle Detected on windows
  • Fix crash on android where the 20th ListView would result in a crash (introduced with DataTemplateSelectors)
  • Fix crash on android when DataTemplateSelectors are used with grouping
  • Fix crash when calling RemovePage on Android AppCompat
  • Fix InsertPageBefore not working properly on Android AppCompat
  • Fix issue in WinRT/UWP ListView not showing data if set after renderer created

Pre-2 Notes

  • Resolve issue where labels didn't resize correctly
  • Resolve issue where AppCompat backend sometimes crashed when looking for a fragment by resource ID.

New Features

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 ItemTemplate=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.

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;

Known Issues

  • Windows ListView may show blank in some cases - Fixed in pre3
  • WinRT reloads toolbar items on navigation even when they haven't changed'
  • RoutingEffect API is not final
  • RoutingEffect will not correctly inherit properties - Fixed in point update
«1345

Posts

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    Nice to see ControlTemplates. Thanks. :)

  • JoeMankeJoeManke USMember ✭✭✭

    <ListView DataTemplate=local:MyDataTemplateSelector />

    I'd like to point out that this line of XAML is incorrect. The property should be ItemTemplate (or HeaderTemplate or FooterTemplate), not DataTemplate.

  • Shane000Shane000 USMember ✭✭✭

    on CustomRenderers we export our renderer with [assembly: ExportRenderer (typeof (BaseEntry), typeof (BaseEntryRenderer))]

    Do the effects use ExportEffect or something else?

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @JoeManke fixed

    @ShanePope yes I am writing up a demo now

  • MichaelRidlandMichaelRidland AUInsider, University ✭✭✭

    Oh what a release.

    Templates and Effects.... Wow...

  • JoeMankeJoeManke USMember ✭✭✭
    edited January 2016

    Testing out the DataTemplateSelector, came across a bug.

    We have a grouped ListView. We were previously using a DataTemplateSelector we wrote ourselves for the ItemTemplate, I'm testing out using the new official one. The ListView also has a GroupHeaderTemplate. OnSelectHeader() of the selector is being called for a group header cell.

    Even after modifying my selector to handle the group headers, and removing the GroupHeaderTemplate from the ListView, I am now getting an ArgumentOutOfRangeException when trying to render this list, with the following stacktrace:

    01-20 17:27:21.405 I/MonoDroid(12004): UNHANDLED EXCEPTION:
    01-20 17:27:21.445 I/MonoDroid(12004): System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    01-20 17:27:21.445 I/MonoDroid(12004): Parameter name: index
    01-20 17:27:21.445 I/MonoDroid(12004):   at (wrapper dynamic-method) System.Object:14e9ab9c-fba9-45cd-8950-0d21d6817e6f (intptr,intptr,int)
    01-20 17:27:21.445 I/MonoDroid(12004):   at (wrapper native-to-managed) System.Object:14e9ab9c-fba9-45cd-8950-0d21d6817e6f (intptr,intptr,int)
    01-20 17:27:21.445 I/MonoDroid(12004):   at (wrapper managed-to-native) System.Object:wrapper_native_0xb4bbe971 (intptr,intptr,intptr,Android.Runtime.JValue*)
    01-20 17:27:21.445 I/MonoDroid(12004):   at (wrapper delegate-invoke) <Module>:invoke_void_intptr_intptr_intptr_JValue* (intptr,intptr,intptr,Android.Runtime.JValue*)
    01-20 17:27:21.445 I/MonoDroid(12004):   at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue* parms) [0x00040] in /Users/builder/data/lanes/2512/d3008455/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:567 
    01-20 17:27:21.445 I/MonoDroid(12004):   at Android.Views.ViewGroup.Layout (Int32 l, Int32 t, Int32 r, Int32 b) [0x00082] in /Users/builder/data/lanes/2512/d3008455/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Views.ViewGroup.cs:3763 
    01-20 17:27:21.445 I/MonoDroid(12004):   at Xamarin.Forms.Platform.Android.ViewRenderer`2[TView,TNativeView].OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) [0x00059] in <filename unknown>:0 
    01-20 17:27:21.445 I/MonoDroid(12004):   at Xamarin.Forms.Platform.Android.ListViewRenderer.OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) [0x00000] in <filename unknown>:0 
    01-20 17:27:21.445 I/MonoDroid(12004):   at Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII (IntPtr jnienv, IntPtr native__this, Boolean p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4) [0x00008] in <filename unknown>:0 
    01-20 17:27:21.445 I/MonoDroid(12004):   at (wrapper dynamic-method) System.Object:fb67fc11-8e8b-4ce5-92d9-d8b8972d6c15 (intptr,intptr,bool,int,int,int,int)
    
  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    are you able to get a breakpoint in there and see what values are being passed to OnLayout?

  • DavidDancyDavidDancy AUMember ✭✭✭✭

    Really like the Effects idea. Should be able to get rid of lots of custom renderers whose only purpose in life was to embellish the stock controls just ever so slightly.

  • Anil.ApexAnil.Apex USMember

    Thankyou for DataTemplateSelector :smile:

  • What about Xamarin.Forms.Maps? Has it googleplayServices 27 as dependency?

    In the nuspec file it is written googleplayservices = 26

    I hope that is a mistake by you!!!

    https://www.nuget.org/packages/Xamarin.Forms.Maps/2.1.0.6501-pre1

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    Bumping GPS is something we are currently evaluating, every time we do it it has the potential to break LARGE amounts of community code so its not something we do just because a new version came out.

  • I saw you downgrade the googleplayservices in Xamarin.Forms. So I don't need the 27.

    I can downgrade my library and my app as well to 26. Thanks for that ;)

  • DavidSpeakDavidSpeak GBUniversity ✭✭

    @TheRealJasonSmith

    Looks like a great release - thanks!

    HasUnevenRows dynamic sizing support

    Does this mean I can create a listview and fill the items with varying lengths of text and different sized images images (and now datatemplates!) and it'll resize each cell to fit automagically? Or is there still some calculation needed by the app as well as the framework?

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    It means that if you do ListView.HasUnevenRows = true you can now call ForceUpdateSize on your cell which will force the cell to dynamically resize, even if it is currently visible. On some platforms this operation can be extremely expensive, so it is not dont automatically, but if you wanted to do so you could hook the MeasureInvalidated event on the Content of your ViewCell and call ForceUpdateSize in there. Again this can be extremely expensive.

  • ThibaultDThibaultD SEMember ✭✭✭

    I like the Effects philosophy too!

    I'm not sure I understand what ControlTemplates are for though, what are the use-cases/possibilities with it?

  • AdamPAdamP AUUniversity ✭✭✭✭✭
    edited January 2016

    I believe hell may have frozen over: ListView Virtualization is now supported on Windows

    And those Windows bugs fixes, love it :) (cough still have 9 outstanding)

    And good work with that little side note "template / effects" update thingy you did. :smiley:

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    Please be aware that the windows support is still in a partial state. While visualization is improved we are still working to further improve memory usage.

  • BradChase.2654BradChase.2654 USMember ✭✭✭
    edited January 2016

    @ThibaultD ControlTemplates and TemplatedBindings are ideas that were used in Sivlerlight & WPF. They let you build true custom controls using just Xamarin Forms. Its a MASSIVE deal! If you would like more info on it really just look up custom control building for Silverlight/WPF. That will give you an idea of how powerful they can be. Also being able to knock a property with Content will be great instead of having developers right XAML like <CustomControl.Body> ... </> to simply fill in the content area because the Content property was already taken by the ContentView. Also YAYYYY to no more a thousand .SetBindings in the code behind!!! We can now set them in the template and the template can be overridden by the developer if they want to change up the control without effecting the purpose of the control.

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    Exists doc for Effect and PanGesture?

  • JoeMankeJoeManke USMember ✭✭✭

    @TheRealJasonSmith These are the parameters being passed to OnLayout of the ListViewRenderer:
    changed = True, l = 24, t = 24, r = 1056, b = 1653

    Looking at my debug output, I'm seeing another stacktrace which I figure is where the exception is really happening:

    (Fatal) - Fatal Exception: Specified argument was out of the range of valid values.
    Parameter name: index   at Xamarin.Forms.ListProxy.get_Item (Int32 index) [0x0000b] in <filename unknown>:0 
    at Xamarin.Forms.Platform.Android.ListViewAdapter.GetItemViewType (Int32 position) [0x00071] in <filename unknown>:0 
    at Android.Widget.BaseAdapter.n_GetItemViewType_I (IntPtr jnienv, IntPtr native__this, Int32 position) [0x00009] in /Users/builder/data/lanes/2512/d3008455/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Widget.BaseAdapter.cs:259 
    at (wrapper dynamic-method) System.Object:5a44bb6a-f09a-4e1f-870f-9d4ee87fddfd (intptr,intptr,int)
    
  • My labels in a StackLayout are no longer expanding vertically when there is more text in them.

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai
    edited January 2016

    @BradChase.2654 you mean like doing

    <ContentPresenter Content="{TemplateBinding Body}" />
    

    Inside of your ControlTemplate which binds up to the Body View on your custom class? Because you can. I'll demo it later.

    @RyanHerman.9335 can you show me? What are they packed in? Need more context

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @AlessandroCaliaro full docs are being worked on and will be available for stable release. I did blog about Effects if you care to go find that.

  • RyanHerman.9335RyanHerman.9335 USMember
    edited January 2016

    @TheRealJasonSmith I thought it was fixed till I readded all the stackpanels to my layouts. If I just have one or two, it is fine, but I think it struggles w/ multiple expansions.

    Basically all the ServerResponse StackLayouts with the Label.

      <ScrollView>
            <StackLayout Padding="10,10,10,10">
                <Button x:Name="MockData" Clicked="MockData_OnClicked" Text="Mock Up" />
                <Label Text="Username:" />
                <customRenderer:DoneEntry x:Name="username" HorizontalOptions="FillAndExpand" VerticalOptions="Center" />
                <StackLayout Padding="5,0">
                    <Label x:Name="ServerResponseUsername" TextColor="Red" />
                </StackLayout>
                <Label Text="Email:" />
                <customRenderer:DoneEntry x:Name="email" HorizontalOptions="FillAndExpand" VerticalOptions="Center"
                                          Keyboard="Email" />
                <StackLayout Padding="5,0">
                    <Label x:Name="ServerResponseEmail" TextColor="Red" />
                </StackLayout>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Switch x:Name="getUpdates" Grid.Column="1" VerticalOptions="Center" />
                    <Label Text="Send me ticket and event updates." FontSize="14" Grid.Column="0"
                           VerticalOptions="Center" />
                </Grid>
    
                <Label Text="Password:" />
                <customRenderer:DoneEntry x:Name="password" HorizontalOptions="FillAndExpand" VerticalOptions="Center"
                                          IsPassword="True" />
                <StackLayout Padding="5,0">
                    <Label x:Name="ServerResponsePassword" TextColor="Red" />
                </StackLayout>
                <Label Text="First Name:" />
                <customRenderer:DoneEntry x:Name="firstName" HorizontalOptions="FillAndExpand" VerticalOptions="Center"
                                          Keyboard="Text" />
    
                <Label Text="Last Name:" />
                <customRenderer:DoneEntry x:Name="lastName" HorizontalOptions="FillAndExpand" VerticalOptions="Center"
                                          Keyboard="Text" />
    
                <Label Text="Mobile Phone:" />
                <customRenderer:DoneEntry x:Name="phone" HorizontalOptions="FillAndExpand" VerticalOptions="Center"
                                          Keyboard="Telephone" />
                <StackLayout Padding="5,0">
                    <Label x:Name="ServerResponsePhone" TextColor="Red" />
                </StackLayout>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Switch x:Name="locationUS" Grid.Column="1" VerticalOptions="Center" />
                    <Label Text="I live in the U.S." FontSize="14" Grid.Column="0"
                           VerticalOptions="Center" />
                </Grid>
    
                <Label Text="U.S Zip Code:" />
                <customRenderer:DoneEntry x:Name="zipCode" HorizontalOptions="FillAndExpand" VerticalOptions="Center"
                                          Keyboard="Numeric" />
                <Label x:Name="ServerResponsZipcode" HorizontalOptions="FillAndExpand"
                       VerticalOptions="FillAndExpand" TextColor="Red" />
                <Label Text="Birth Date" />
                <DatePicker x:Name="birthday" />
                <StackLayout Padding="5,0">
                    <Label x:Name="ServerResponseBirthday" TextColor="Red" />
                </StackLayout>
                <Label Text="Gender" />
                <Picker x:Name="Gender" />
    
                <Label x:Name="ServerResponse" TextColor="White" />
    
                <Button Text="Create Account" HorizontalOptions="FillAndExpand" VerticalOptions="Center"
                        x:Name="createButton" Clicked="CreateButton_OnClicked" />
            </StackLayout>
        </ScrollView>
    
  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @RyanHerman.9335 think you could boil that down to just the parts that matter OR hop on skype with me and go over this live?

  • @TheRealJasonSmith Lets do Skype? How should I contact you?

  • @TheRealJasonSmith I found another place where the Label does not expand to the next line. I am thinking it is a problem with the label text going to the next lines.

  • BradChase.2654BradChase.2654 USMember ✭✭✭

    @TheRealJasonSmith said:
    @BradChase.2654 you mean like doing

    Inside of your ControlTemplate which binds up to the Body View on your custom class? Because you can. I'll demo it later.

    Yup!!! Woooooo excited! Can't say that enough! I felt like I was ugly hacking away there at controls hoping this would come!

  • RogerSchmidlinRogerSchmidlin CHUniversity ✭✭✭

    I got the same issues with expanding labels. My text gets cut off. My labels are sitting next to a slider, which changes the content of the label. This works fine in the just recent official release but not in the pre release.

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    we're trying to track it down now

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai
    edited January 2016

    Which platform are you seeing this behavior on? All?

    Edit: so it turns out UITest doesn't really work to pick up this kind of failure the way we coded the test, woops.

    Edit2: Okay the problem was caused by the change we made to fix this: https://bugzilla.xamarin.com/show_bug.cgi?id=37675 We are reverting the change until we can evaluate a different method of fixing it or if we want to simply codify that behavior as expected.

  • @TheRealJasonSmith @JoeManke

    I'm seeing exact the same bug when changing our grouped ListView to use the new DataTemplateSelectors:

    I/MonoDroid(11945): UNHANDLED EXCEPTION:
    I/MonoDroid(11945): System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    I/MonoDroid(11945): Parameter name: index
    I/MonoDroid(11945):   at Xamarin.Forms.ListProxy.get_Item (Int32 index) <0xdaf24490 + 0x00063> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.ListViewAdapter.GetItemViewType (Int32 position) <0xd90f4508 + 0x0010f> in <filename unknown>:0
    I/MonoDroid(11945):   at Android.Widget.BaseAdapter.n_GetItemViewType_I (IntPtr jnienv, IntPtr native__this, Int32 position) <0xd90f44c8 + 0x00039> in <filename unknown>:0
    I/MonoDroid(11945):   at (wrapper dynamic-method) System.Object:fad083cf-8dc2-4a66-a43e-b822c770a6a0 (intptr,intptr,int)
    W/Xamarin.Insights(11945): Warning: Unhandled exception: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    W/Xamarin.Insights(11945): Parameter name: index
    W/Xamarin.Insights(11945):   at Xamarin.Forms.ListProxy.get_Item (Int32 index) <0xdaf24490 + 0x00063> in <filename unknown>:0
    W/Xamarin.Insights(11945):   at Xamarin.Forms.Platform.Android.ListViewAdapter.GetItemViewType (Int32 position) <0xd90f4508 + 0x0010f> in <filename unknown>:0
    W/Xamarin.Insights(11945):   at Android.Widget.BaseAdapter.n_GetItemViewType_I (IntPtr jnienv, IntPtr native__this, Int32 position) <0xd90f44c8 + 0x00039> in <filename unknown>:0
    W/Xamarin.Insights(11945):   at (wrapper dynamic-method) System.Object:fad083cf-8dc2-4a66-a43e-b822c770a6a0 (intptr,intptr,int)
    W/art     (11945): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable
    I/MonoDroid(11945): UNHANDLED EXCEPTION:
    I/MonoDroid(11945): System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    I/MonoDroid(11945): Parameter name: index
    I/MonoDroid(11945):   at Xamarin.Forms.ListProxy.get_Item (Int32 index) <0xdaf24490 + 0x00063> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.ListViewAdapter.GetItemViewType (Int32 position) <0xd90f4508 + 0x0010f> in <filename unknown>:0
    I/MonoDroid(11945):   at Android.Widget.BaseAdapter.n_GetItemViewType_I (IntPtr jnienv, IntPtr native__this, Int32 position) <0xd90f44c8 + 0x00039> in <filename unknown>:0
    I/MonoDroid(11945):   at (wrapper dynamic-method) System.Object:fad083cf-8dc2-4a66-a43e-b822c770a6a0 (intptr,intptr,int)
    I/MonoDroid(11945): --- End of stack trace from previous location where exception was thrown ---
    I/MonoDroid(11945):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xd7f5ec40 + 0x0002b> in <filename unknown>:0
    I/MonoDroid(11945):   at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue* parms) <0xdc070850 + 0x00097> in <filename unknown>:0
    I/MonoDroid(11945):   at Android.Views.ViewGroup.Layout (Int32 l, Int32 t, Int32 r, Int32 b) <0xdaed5670 + 0x00177> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.ViewRenderer`2[TView,TNativeView].OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) <0xdaed5418 + 0x000ee> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.ListViewRenderer.OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) <0xdaed5390 + 0x00037> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII (IntPtr jnienv, IntPtr native__this, Boolean p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4) <0xdaed5208 + 0x00056> in <filename unknown>:0
    I/MonoDroid(11945):   at (wrapper dynamic-method) System.Object:d9c310b2-0dc7-422e-890c-80b7c45f49f6 (intptr,intptr,bool,int,int,int,int)
    I/MonoDroid(11945): UNHANDLED EXCEPTION:
    I/MonoDroid(11945): System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    I/MonoDroid(11945): Parameter name: index
    I/MonoDroid(11945):   at Xamarin.Forms.ListProxy.get_Item (Int32 index) <0xdaf24490 + 0x00063> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.ListViewAdapter.GetItemViewType (Int32 position) <0xd90f4508 + 0x0010f> in <filename unknown>:0
    I/MonoDroid(11945):   at Android.Widget.BaseAdapter.n_GetItemViewType_I (IntPtr jnienv, IntPtr native__this, Int32 position) <0xd90f44c8 + 0x00039> in <filename unknown>:0
    I/MonoDroid(11945):   at (wrapper dynamic-method) System.Object:fad083cf-8dc2-4a66-a43e-b822c770a6a0 (intptr,intptr,int)
    I/MonoDroid(11945): --- End of stack trace from previous location where exception was thrown ---
    I/MonoDroid(11945):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xd7f5ec40 + 0x0002b> in <filename unknown>:0
    I/MonoDroid(11945):   at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue* parms) <0xdc070850 + 0x00097> in <filename unknown>:0
    I/MonoDroid(11945):   at Android.Views.ViewGroup.Layout (Int32 l, Int32 t, Int32 r, Int32 b) <0xdaed5670 + 0x00177> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.ViewRenderer`2[TView,TNativeView].OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) <0xdaed5418 + 0x000ee> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.ListViewRenderer.OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) <0xdaed5390 + 0x00037> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII (IntPtr jnienv, IntPtr native__this, Boolean p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4) <0xdaed5208 + 0x00056> in <filename unknown>:0
    I/MonoDroid(11945):   at (wrapper dynamic-method) System.Object:d9c310b2-0dc7-422e-890c-80b7c45f49f6 (intptr,intptr,bool,int,int,int,int)
    I/MonoDroid(11945): --- End of stack trace from previous location where exception was thrown ---
    I/MonoDroid(11945):   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xd7f5ec40 + 0x0002b> in <filename unknown>:0
    I/MonoDroid(11945):   at Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod, Android.Runtime.JValue* parms) <0xdc10d6f0 + 0x000b3> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.FormsViewGroup.MeasureAndLayout (Int32 p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4, Int32 p5) <0xdaed4f60 + 0x00277> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.VisualElementTracker.UpdateLayout () <0xdaed4c00 + 0x001f2> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].UpdateLayout () <0xdaed4bd0 + 0x0001f> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) <0xdaed5270 + 0x0009e> in <filename unknown>:0
    I/MonoDroid(11945):   at Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII (IntPtr jnienv, IntPtr native__this, Boolean p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4) <0xdaed5208 + 0x00056> in <filename unknown>:0
    I/MonoDroid(11945):   at (wrapper dynamic-method) System.Object:d9c310b2-0dc7-422e-890c-80b7c45f49f6 (intptr,intptr,bool,int,int,int,int)
    
  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai
    edited January 2016

    @BastiBrauning we're digging into it, are you using the DTS on the ItemTemplate or the HeaderTemplate?

  • Thanks for the fast response!

    Tried using it on ItemTemplate and GroupHeaderTemplate. (Using it signly on ItemTemplate the same crash occurs).

    Basically this is my ListView:

     <ListView            
                SeparatorVisibility="None"
                ItemsSource="{Binding MyItems}"
                IsPullToRefreshEnabled="True"            
                IsGroupingEnabled="True"
                GroupDisplayBinding="{Binding .}"
                HasUnevenRows="True"
                Footer="{Binding .}" 
                CachingStrategy="RecycleElement">
    
            <ListView.FooterTemplate>         
              <DataTemplate>
                <footer:MyFooterCell/>
              </DataTemplate>
            </ListView.FooterTemplate>
    
            <ListView.ItemTemplate>
              <template:MyDataTemplateSelector/>
            </ListView.ItemTemplate>
    
            <ListView.GroupHeaderTemplate>
              <template:MyDataTemplateSelector/>
            </ListView.GroupHeaderTemplate>    
    
    <ListView>
    
  • Attached small sample project to reproduce issue.

  • RenaudLaloireRenaudLaloire BEUniversity ✭✭

    Big huge thanks for the ControlTemplates addition, this is such a game changer in building re-usable custom controls framework. I can now re-implement every control I made so far but I am really excited about it !!!

    Thanks again !!!

  • RenaudLaloireRenaudLaloire BEUniversity ✭✭

    @TheRealJasonSmith quick question: does the ControlTemplate mechanism adds performance degradation compared to building the same screen without ControlTemplate ?

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    Nothing beyond what you expect in terms of "it has to inflate the template" and "whatever I put in the template is in the visual hierarchy"

  • I also experience a lot of "Java.Lang.ArrayIndexOutOfBoundsException" on Android while fastly scrolling a ListView up/down (Recycling).

    I sadly can't track it exactly down to make a sample reproducement.

    Java.Lang.ArrayIndexOutOfBoundsExceptionlength=20; index=21
    Raw
      at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0xd801b600 + 0x0002b> in <filename unknown>:0 
      at Android.Runtime.JNIEnv.CallVoidMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue* parms) <0xdc054d08 + 0x00097> in <filename unknown>:0 
      at Android.Views.ViewGroup.Layout (Int32 l, Int32 t, Int32 r, Int32 b) <0xdb2fe0b8 + 0x00177> in <filename unknown>:0 
      at Xamarin.Forms.Platform.Android.ViewRenderer`2[TView,TNativeView].OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) <0xdb2fde60 + 0x000ee> in <filename unknown>:0 
      at Xamarin.Forms.Platform.Android.ListViewRenderer.OnLayout (Boolean changed, Int32 l, Int32 t, Int32 r, Int32 b) <0xdb2fddd8 + 0x00037> in <filename unknown>:0 
      at Xamarin.Forms.Platform.Android.FormsViewGroup.n_OnLayout_ZIIII (IntPtr jnienv, IntPtr native__this, Boolean p0, Int32 p1, Int32 p2, Int32 p3, Int32 p4) <0xdb2fdc50 + 0x00056> in <filename unknown>:0 
      at (wrapper dynamic-method) System.Object:9d0128f1-255e-408e-a785-b518876a088c (intptr,intptr,bool,int,int,int,int)
      --- End of managed exception stack trace ---
    java.lang.ArrayIndexOutOfBoundsException: length=20; index=21
        at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:6588)
        at android.widget.ListView.layoutChildren(ListView.java:1632)
        at android.widget.AbsListView.onLayout(AbsListView.java:2151)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:581)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewRenderer.n_onLayout(Native Method)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewRenderer.onLayout(ListViewRenderer.java:64)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onLayout(Native Method)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.onLayout(VisualElementRenderer_1.java:48)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onLayout(Native Method)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.onLayout(VisualElementRenderer_1.java:48)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onLayout(Native Method)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.onLayout(VisualElementRenderer_1.java:48)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onLayout(Native Method)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.onLayout(VisualElementRenderer_1.java:48)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
        at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.n_onLayout(Native Method)
        at md5270abb39e60627f0f200893b490a1ade.NavigationPageRenderer.onLayout(NavigationPageRenderer.java:62)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at com.xamarin.forms.platform.android.FormsViewGroup.measureAndLayout(FormsViewGroup.java:29)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.MasterDetailContainer.n_onLayout(Native Method)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.MasterDetailContainer.onLayout(MasterDetailContainer.java:53)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1043)
        at md5270abb39e60627f0f200893b490a1ade.MasterDetailPageRenderer.n_onLayout(Native Method)
        at md5270abb39e60627f0f200893b490a1ade.MasterDetailPageRenderer.onLayout(MasterDetailPageRenderer.java:67)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.n_onLayout(Native Method)
        at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.onLayout(PlatformRenderer.java:62)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
        at android.view.View.layout(View.java:15671)
        at android.view.ViewGroup.layout(ViewGroup.java:5038)
        at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2086)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1843)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
        at android.view.Choreographer.doCallbacks(Choreographer.java:580)
        at android.view.Choreographer.doFrame(Choreographer.java:550)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5254)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
    
«1345
Sign In or Register to comment.