/// <inheritdoc/>
        public override void BindTo(ViewModel viewModel)
        {
            bool bind = viewModel != null;

            if ((viewModel ?? Model) is SearchViewModel svm)
            {
                if (btn_Select != null && bind && svm.Params != null)
                {
                    btn_Select.Visible = (svm.Params[ViewParams.SelectionMode.Param] != null);
                }

                // subscribe to property change events on the data list object
                if (bind)
                {
                    if (svm.List != null)
                    {
                        svm.List.PropertyChanged += OnListPropertyChanged;
                    }
                    // persist the object in session
                    ListObj = svm.List;
                }
                else
                {
                    if (svm.List != null)
                    {
                        svm.List.PropertyChanged -= OnListPropertyChanged;
                    }
                }
                OnModelPropertyChanged(svm, new PropertyChangedEventArgs(SearchViewModel.CriteriaCollapsedProperty));
                OnListPropertyChanged(bind ? svm.List : null, new PropertyChangedEventArgs(nameof(DataListObject.AppliedCriteria)));

                if (svm.List != null && grd_Results != null)
                {
                    if (svm.List.CriteriaObject != null && ucl_Criteria != null)
                    {
                        ucl_Criteria.DataBind();
                        WebPropertyBinding.BindToObject(ucl_Criteria, bind ? svm.List.CriteriaObject : null);
                        if (svm.List.AppliedCriteria != null) // recalculate applied criteria with updated labels after binding
                        {
                            svm.List.AppliedCriteria = svm.List.CriteriaObject.GetFieldCriteriaSettings();
                        }
                    }
                    if (grd_Results != null)
                    {
                        grd_Results.AutoGenerateSelectButton = ViewParams.SelectionMode.Single.Equals(svm.Params[ViewParams.SelectionMode.Param]);
                        WebPropertyBinding.BindToList(grd_Results, bind ? svm.List : null);
                    }
                }
            }
            base.BindTo(viewModel);
        }
Exemple #2
0
        /// <summary>
        /// Binds the view to its model, or unbinds the current model if null is passed.
        /// </summary>
        /// <param name="viewModel">Model to bind the view to</param>
        public override void BindTo(ViewModel viewModel)
        {
            bool            bind = viewModel != null;
            SearchViewModel svm  = (bind ? viewModel : this.Model) as SearchViewModel;

            if (svm != null)
            {
                if (btn_Select != null && bind && svm.Params != null)
                {
                    btn_Select.Visible = (svm.Params[ViewParams.SelectionMode.Param] != null);
                }

                // subscribe to property change events on the data list object
                if (bind)
                {
                    if (svm.List != null)
                    {
                        svm.List.PropertyChanged += OnListPropertyChanged;
                    }
                    // persist the object in session
                    listObj = svm.List;
                }
                else
                {
                    if (svm.List != null)
                    {
                        svm.List.PropertyChanged -= OnListPropertyChanged;
                    }
                }
                OnModelPropertyChanged(svm, new PropertyChangedEventArgs(SearchViewModel.CriteriaCollapsedProperty));
                OnListPropertyChanged(bind ? svm.List : null, new PropertyChangedEventArgs(DataListObject.AppliedCriteriaProperty));

                if (svm.List != null && grd_Results != null)
                {
                    if (svm.List.CriteriaObject != null && ucl_Criteria != null)
                    {
                        ucl_Criteria.DataBind();
                        WebPropertyBinding.BindToObject(ucl_Criteria, bind ? svm.List.CriteriaObject : null);
                    }
                    if (grd_Results != null)
                    {
                        grd_Results.AutoGenerateSelectButton = ViewParams.SelectionMode.Single.Equals(svm.Params[ViewParams.SelectionMode.Param]);
                        WebPropertyBinding.BindToList(grd_Results, bind ? svm.List : null);
                    }
                }
            }
            base.BindTo(viewModel);
        }
Exemple #3
0
        /// <summary>
        /// Binds the view to its model, or unbinds the current model if null is passed.
        /// </summary>
        /// <param name="viewModel">Model to bind the view to</param>
        public override void BindTo(ViewModel viewModel)
        {
            bool             bind = viewModel != null;
            DetailsViewModel dvm  = (bind ? viewModel : this.Model) as DetailsViewModel;

            if (dvm != null)
            {
                if (dvm.DetailsObject != null && pnl_Object != null)
                {
                    pnl_Object.DataBind();
                    WebPropertyBinding.BindToObject(pnl_Object, bind ? dvm.DetailsObject : null);
                }
                if (bind)
                {
                    dataObj = dvm.DetailsObject;       // persist the object in session
                }
            }
            base.BindTo(viewModel);
        }
        /// <inheritdoc/>
        public override void BindTo(ViewModel viewModel)
        {
            bool bind = viewModel != null;

            if ((viewModel ?? Model) is DetailsViewModel dvm)
            {
                if (dvm.DetailsObject != null && pnl_Object != null)
                {
                    pnl_Object.DataBind();
                    WebPropertyBinding.BindToObject(pnl_Object, bind ? dvm.DetailsObject : null);
                }
                if (bind)
                {
                    DataObj = dvm.DetailsObject;       // persist the object in session
                }
                else
                {
                    dvm.DetailsObject = null;  // detach view model from persisted object
                }
            }
            base.BindTo(viewModel);
        }