I'm facing a very strange behaviour with mvvmcross and xamarin. Since today i can't populate any MvxListView, MvxLinearLayout etc anymore.
Here is what i know :
All views of those types i created earlier (the last one working was created last week) still works fine and are populated
If i try to create a new one it won't display any child item.
If i set a background color or any stylish element to my view i will be able to see it. But if i do the same for the item template it won't show up.
If I click on my MvxListView, the output will say this :
07-12 16:29:09.154 W/AbsListView(26069): Intent to operate on non-exist data, childcount=0, mFirstPosition=0, mItemCount=0, adapter count=0, mAdapter=md5bf0126c95bf9fc0db24c02c9adb4cfa7.MvxAdapter@3fbd5398, action=1, mActivePointerId=0, mScrollY=0, this=mvvmcross.binding.droid.views.MvxListView{12a517f1 V.ED.VC......... 15,15-196,912}
- If i add a new MvxListView near an old one, bind it to the same dataset, i will still encounter the same problem.
Does anyone have any idea ? I highly suspect the last Xamarin Update to be causing this, so i upgraded Mvmmcross believing they fixed it as the last update is one day old (07/11/2016) but this didn't help.
Update :
After more investigations i can tell that i'm not able to create new custom bindings neither. Looks like the binding engine is absolutely dead for my project. All bindings done before monday 07/11/2016 are working, any new one won't and i haven't found any workaround yet
Update 2 :
As requested here is some code, but i would like to say that the very same bug will occur even if i use a normal MvxListView with itemSource binded on a list of string or any kind of dataset.
I just created this custom view to use it as a workaround, believing that regisetering my own custom binding could somehow "override" the broken binding system.
WokingMvxListView :
public class WorkingMvxListView : MvxListView
{
private ObservableCollection<TimingControlModel> _timings;
//TimingControlModel is some class containing timespan and floats etc
public ObservableCollection<TimingControlModel> Timings
{
get
{
return _timings;
}
set
{
_timings = value;
ItemSource = value;
}
}
public WorkingMvxListView(Context context, IAttributeSet attrs) : base(context, attrs)
{
}
public WorkingMvxListView(Context context, IAttributeSet attrs, IMvxAdapter adapter) : base (context, attrs, adapter)
{
}
protected WorkingMvxListView(IntPtr javaReference, JniHandleOwnership transfer): base(javaReference, transfer)
{
}
}
TargetBinding :
public class MvxVogofCustomListViewTimersBinding : MvxAndroidTargetBinding
{
private readonly bool _isVogofWorkingMvxListViewBinding;
public MvxVogofCustomListViewTimersBinding(WorkingMvxListView target) : base(target)
{
if(target==null)
{
MvxBindingTrace.Trace(MvxTraceLevel.Error, "Error WorkingMvxListView is null in MvxVogofMediaControllerFileNameBinding");
return;
}
_isVogofWorkingMvxListViewBinding = target is WorkingMvxListView;
}
public override Type TargetType
{
get
{
return typeof(ObservableCollection<TimingControlModel>);
}
}
public override void SetValue(object value)
{
base.SetValue(value);
}
protected override void SetValueImpl(object target, object value)
{
((WorkingMvxListView)target).Timings = (ObservableCollection<TimingControlModel>)value;
}
public override MvxBindingMode DefaultMode
{
get { return MvxBindingMode.OneWay; }
}
}
Setup.cs :
protected override void FillTargetFactories(IMvxTargetBindingFactoryRegistry registry)
{
registry.RegisterFactory(new MvxCustomBindingFactory<WorkingMvxListView>("Timings", (workingMvxListView) => new MvxVogofCustomListViewTimersBinding(workingMvxListView)));
}
ViewModel :
private ObservableCollection<TimingControlModel> _timings;
public ObservableCollection<TimingControlModel> Timings
{
get
{
return _timings;
}
set
{
_timings = value;
RaisePropertyChanged(() => Timings);
}
}
View.axml :
<Vogof.Droid.Views.CustomViews.WorkingMvxListView
android:id="@+id/TimersList"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/White"
android:layout_margin="10dp"
android:divider="#DDDDDD"
android:dividerHeight="4px"
local:MvxItemTemplate="@layout/template_timer_item"
local:MvxBind="Timings Timings" />
<!--Yes i know Timings Timings sounds terrible, but it is for test purposes-->
ItemTemplate.axml :
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#050506"
android:background="@color/Black"
android:paddingLeft="5dp"
android:layout_marginBottom="1dp"
android:layout_marginTop="1dp"
local:MvxBind="Text TimeToDisplay"
android:textAppearance="?android:attr/textAppearanceLarge" />
Update 3 :
By adding ItemSource=value in my WorkingMvxListView, after downgrading Xamarin to 4.0.3, removing all my android sdk's, installing the ones recommended here by angelocarlotto, i'm finally able to have data in my WorkingMvxListViewModel !
But the real problem, that i can't bind on normal MvxListView, still persist