Ejemplo n.º 1
0
        public PropertyCollectionBinding(DataContext <T> set, int ViewGroupLayoutID, Android.Content.Context context, Expression <Func <T, ObservableCollection <U> > > property, int ItemLayoutID, VMListAdapter <U> .BindEvents BindEvents, VMListAdapter <U> .BindViewModel BindViewModel)
            : base(set, ViewGroupLayoutID, (MemberExpression)property.Body, "ChildCount", null, null)
        {
            list = VMProperty.GetValue(Set.VM, null) as ObservableCollection <U>;
            if (list == null)
            {
                throw new ArgumentOutOfRangeException("Property");
            }
            if (!(View is ViewGroup))
            {
                throw new ArgumentOutOfRangeException("ViewGroupLayoutID");
            }

            list.CollectionChanged += (sender, e) => { FromVM(); };

            adapter = new VMListAdapter <U>(context, list, ItemLayoutID, BindEvents, BindViewModel);
        }
Ejemplo n.º 2
0
        public override void FromVM()
        {
            try
            {
                ObservableCollection <U> value = VMProperty.GetValue(Set.VM, null) as ObservableCollection <U>;
                if (value != list)
                {
                    throw new Exception("Changing the list reference is not supported yet");
                }

//				ViewGroup view = View as ViewGroup;
//
//				view.RemoveAllViews();
//				for (int i = 0; i < adapter.Count; i++)
//					view.AddView(adapter.GetView(i, null, view));
            }
            catch (Exception ex)
            {
                LittleWatson.ReportException(ex);
            }
        }