Exemple #1
0
 private void SetItemBackground(View view, LazyListItemViewModel item)
 {
     if (item.IsSelected && this.DataContext.MultiSelectionEnabled)
     {
         view.SetBackgroundResource(Resource.Color.blue_200);
     }
     else
     {
         view.SetBackgroundColor(Color.Transparent);
     }
 }
Exemple #2
0
        private View GetAdapter(LazyListItemViewModel item)
        {
            var view = this.LayoutInflater.Inflate(Resource.Layout.LazyListItemTemplate, null);

            var checkbox = view.FindViewById <CheckBox>(Resource.Id.listviewtemplate_check);

            checkbox.Focusable            = false;
            checkbox.FocusableInTouchMode = false;

            this.DataContext.SetBinding <bool, ViewStates>(nameof(this.DataContext.MultiSelectionEnabled),
                                                           checkbox, nameof(CheckBox.Visibility), BindingMode.OneWay)
            .ConvertSourceToTarget(BoolToViewStatesConverter.TrueToVisibleInstance.Convert);

            item.SetBinding <bool, bool>(nameof(item.IsSelected),
                                         checkbox, nameof(CheckBox.Checked), BindingMode.TwoWay)
            .WhenSourceChanges(() => this.SetItemBackground(view, item));

            item.SetBinding <string, string>(nameof(item.Title), view.FindViewById <TextView>(Resource.Id.listviewtemplate_title),
                                             nameof(TextView.Text), BindingMode.OneWay);

            return(view);
        }