This is a migrated thread and some comments may be shown as answers.

iOS - RadListView - Binding not updated when using ItemTemplateSelector

3 Answers 114 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Remi
Top achievements
Rank 1
Remi asked on 13 Mar 2018, 03:02 PM

I recently noticed that binding is not reevaluated on iOS, when using an ItemTemplateSelector along with a RadListView (latest Telerik nugets as of today), on VM property that is bound with a converter.

Here is the RadListView definition:

<dataControls:RadListView ItemsSource="{Binding MyObservableCollection}"
                                          ItemTemplateSelector="{StaticResource MyTemplateSelector}"
                                          SelectionMode="None">

 

Here MyTemplateSelector:

<DataTemplate x:Key="DefaultTemplate">
                <listView:ListViewTemplateCell>
                    <listView:ListViewTemplateCell.View>
                        <views:MyCellView />
                    </listView:ListViewTemplateCell.View>
                </listView:ListViewTemplateCell>
            </DataTemplate>
 
            <DataTemplate x:Key="EmptyTemplate">
                <listView:ListViewTemplateCell>
                    <listView:ListViewTemplateCell.View>
                        <Grid HeightRequest="60" />
                    </listView:ListViewTemplateCell.View>
                </listView:ListViewTemplateCell>
            </DataTemplate>
 
            <selectors:MyTemplateSelector x:Key="MyTemplateSelector"
                                                                DefaultTemplate="{StaticResource DefaultTemplate}"
                                                                EmptyTemplate="{StaticResource EmptyTemplate}" />

Here is the binding definition in  "DefaultTemplate":

<Label Grid.Row="3" Grid.Column="1"
            Text="{Binding MyStringProperty, Converter={StaticResource MyStringToStringConverter}}"
            Style="{StaticResource MyTextStyle}" />

 

To reproduce, I simply call RaisePropertyChange(nameof(MyStringProperty)) in VMs displayed in the RadListView, and the view does not get updated.

This is perfectly working on Android, and on both Android and iOS when not using any ItemTemplateSelector.

 

NB : this is not linked to this issue.

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 15 Mar 2018, 01:59 PM
Hi Remi,

I will need more details on the scenario you have in order to replicate the erroneous behavior at our side.  I have attached to this thread my test app based on the provided snippets, I have tried on Android and iOS and the binding is reevaluated properly. Could you download the example and give it a try? What is different in your case?

Looking forward to your reply.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Remi
Top achievements
Rank 1
answered on 16 Mar 2018, 11:03 AM

Hi Yana,

Thanks for your reply, I confirm that your project works fine and that binding is updated on my side as well.

The trouble is our architecture is much more complex, as we're using Prism andPubSubEvents in order to communicate between various VMs, and INotifyPropertyChanged is implemented in a custom way on our VMs.

Actually, we were using Background thread when subscribing to the update event, and that explains why the binding was not evaluated. When using Publisher thread, though, along with a template selector, there is a NullReference exception occurring in Telerik code. When removing the ItemTemplateSelector, this is not happening any more.

Unfortunately, I don't have time right now to extract our code in order to reproduce the issue, all I can do for now id to provide you with the stack trace we're seeing when using publisher thread, though I doubt it will be of any use for you:

System.ArgumentNullException: Value cannot be null.
Parameter name: cell
  at TelerikUI.TKListView.IndexPathForCell (TelerikUI.TKListViewCell cell) [0x00003] in <ced3116409594e8cbb777ed8f2292304>:0
  at Telerik.XamarinForms.DataControlsRenderer.iOS.ListViewRenderer.OnItemPropertyChanged (System.Object item) [0x0003d] in <dedd3476e3f04fb1ab543263db9c2650>:0
  at Telerik.XamarinForms.DataControls.RadListView+<>c__DisplayClass115_0.<OnItemsSourcePropertyChanged>b__0 (System.Object sender, System.ComponentModel.PropertyChangedEventArgs eventArgs) [0x0000d] in <dedd3476e3f04fb1ab543263db9c2650>:0
  at Telerik.XamarinForms.DataControls.ItemsSourceWatcher.<AddPropertyChangedListener>b__7_0 (Telerik.XamarinForms.DataControls.ItemsSourceWatcher listener, System.Object sender, System.ComponentModel.PropertyChangedEventArgs eventArgs) [0x0000a] in <dedd3476e3f04fb1ab543263db9c2650>:0
  at Telerik.XamarinForms.Common.WeakEventListener`3[TListener,TEventSource,TEventArgs].OnEvent (System.Object sender, TEventArgs eventArgs) [0x00023] in <3d4fa5c4eaf64278ac261e8c3fd77d91>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.20/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
--- End of stack trace from previous location where exception was thrown ---

 

Should I find any further info, I'd sure let you know.

 

Regards,

Rémi

0
Yana
Telerik team
answered on 20 Mar 2018, 01:41 PM
Hello Rémi,

Indeed, the StackTrace is not quite helpful for us to further research the case.

Please take your time and if, at some point you return to the issue, send us any additional details you might have, so we to be able to assist accordingly.

Regards,
Yana
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListView
Asked by
Remi
Top achievements
Rank 1
Answers by
Yana
Telerik team
Remi
Top achievements
Rank 1
Share this question
or