Note that there are some explanatory texts on larger screens.

plurals
  1. POItemsSource is empty in constructor of Custom Bound Horizontal ScrollView
    text
    copied!<p>I'm having trouble updating Cheesebarons horizontal list view to the new v3 MvvmCross. Everything seems to be working correctly except in the constructor of my "BindableHorizontalListView" control the ItemsSource of the adapter is null. Which is weird because the context shows that the view-model property I am attempting to bind to shows very clearly there are 3 items and the binding seems very straightforward. What am I missing? I hope I've included enough of the code. I've also tried binding it via fluent bindings on the "OnViewModelSet" event with the same result.</p> <p>Warning presented </p> <pre><code>[MvxBind] 24.87 Unable to bind: source property source not found Cirrious.MvvmCross.Binding.Parse.PropertyPath.PropertyTokens.MvxPropertyNamePropertyToken on DeviceViewModel </code></pre> <p>AXML</p> <pre><code> &lt;BindableHorizontalListView android:id="@+id/listView" android:layout_width="fill_parent" android:layout_height="fill_parent" local:MvxBind="ItemsSource DevicesList; ItemClick ItemSelected" local:MvxItemTemplate="@layout/devices_horizontal_list_item" /&gt; </code></pre> <p>BindableHorizontalListView control</p> <pre><code>using System.Collections; using System.Windows.Input; using Android.Content; using Android.Util; using Cirrious.MvvmCross.Binding.Attributes; using Cirrious.MvvmCross.Binding.Droid.Views; namespace Project.Droid.Controls { public class BindableHorizontalListView : HorizontalListView //Which inherits from AdapterView&lt;BaseAdapter&gt; { public BindableHorizontalListView(Context context, IAttributeSet attrs) : this(context, attrs, new MvxAdapter(context)) { } public BindableHorizontalListView(Context context, IAttributeSet attrs, MvxAdapter adapter) : base(context, attrs) { InitView (); var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId (context, attrs); adapter.ItemTemplateId = itemTemplateId; Adapter = adapter; SetupItemClickListener(); } public new MvxAdapter Adapter { get { return base.Adapter as MvxAdapter; } set { var existing = Adapter; if (existing == value) return; if (existing != null &amp;&amp; value != null) { value.ItemsSource = existing.ItemsSource; value.ItemTemplateId = existing.ItemTemplateId; } base.Adapter = value; } } [MvxSetToNullAfterBinding] public IEnumerable ItemsSource { get { return Adapter.ItemsSource; } set { Adapter.ItemsSource = value; this.Reset (); } } public int ItemTemplateId { get { return Adapter.ItemTemplateId; } set { Adapter.ItemTemplateId = value; } } public new ICommand ItemClick { get; set; } private void SetupItemClickListener() { base.ItemClick += (sender, args) =&gt; { if (null == ItemClick) return; var item = Adapter.GetItem(args.Position) as Java.Lang.Object; if (item == null) return; if (item == null) return; if (!ItemClick.CanExecute(item)) return; ItemClick.Execute(item); }; } } } </code></pre> <p>View</p> <pre><code>[Activity (Label = "Device", ScreenOrientation = ScreenOrientation.Portrait)] public class DeviceView : MvxActivity { protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView(Resource.Layout.device); } } </code></pre> <p>Property on ViewModel</p> <pre><code>private Services.Device[] _devicesList; public Services.Device[] DevicesList { get { return _devicesList; } set { _devicesList = value; RaisePropertyChanged(() =&gt; DevicesList); } } </code></pre> <p>If only there was PCL support in XAM STUDIO I would just step in and see how the other controls are doing it!!!! </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload