1

I have an Listview who contains the following xml as list item:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_marginTop="20dp"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:textAppearance="?android:attr/textAppearanceMedium"
        local:MvxBind="Text Key" />
    <MvvmCross.Droid.Support.V7.RecyclerView.MvxRecyclerView
        android:id="@+id/inner_payment_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        local:MvxItemTemplate="@layout/listitem_payment"
        local:MvxBind="ItemsSource .;ItemClick ItemClickCommand; ItemLongClick ItemLongClickCommand" />
</LinearLayout>

View Model:

    /// <summary>
    ///     Returns groupped related payments
    /// </summary>
    public ObservableCollection<DateListGroup<DateListGroup<PaymentViewModel>>> Source
    {
        get { return source; }
        set
        {
            source = value;
            RaisePropertyChanged();
            // ReSharper disable once ExplicitCallerInfoArgument
            RaisePropertyChanged(nameof(IsPaymentsEmtpy));
        }
    }

In my View Model I bind my items via an Observable Collection to the list and to the Recyclerview. This works so far. But when I scroll now, the recyclview displays the same items again. I can then scroll up and down again and mostly the correct items are displayed then. So somehow it seems it loads to slow. Is there a way to prevent that behaviour?

NPadrutt
  • 3,619
  • 5
  • 24
  • 60
  • Instead of doing this `ItemsSource .`, bind directly to your `ObservableCollection`...Ex: `ItemsSource MyList` – pnavk Dec 24 '16 at 23:45
  • The data context is my ObservableCollection. So the point refrences directly to it. – NPadrutt Dec 24 '16 at 23:47
  • The other bindings in your layout suggest otherwise, for example `ItemClick ItemClickCommand` or even `Text Key` suggest that the DataContext is the ViewModel for the Fragment/Activity, not the ObservableCollection. The ObservableCollection is just a bindable property on the ViewModel, just like Key or ItemClickCommand. See here: http://stackoverflow.com/questions/31142106/what-does-binding-do – pnavk Dec 25 '16 at 00:20
  • Ah, yes. I updated my orignal post with the property of the overservable collection. The DateListGroup inherits from a Lis and Contains a Property for the click commands. – NPadrutt Dec 25 '16 at 00:25

0 Answers0