Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2290
Expand XamGrid Groups
posted

Hi Stefan,

We are using XamGrid and have made a column IsGroupBy=True to apply grouping by default and it is working fine except one thing that we want to make all rows expanded. We are using MVVM so can you help us in this regard. I use the XamGrid's Laoded and my code is

 public static void ExpandAllGroups(XamGrid grid)
        {
            if (grid != null)
            {
                foreach (Row item in grid.Rows)
                {
                    if (item.RowType == RowType.GroupByRow)
                    {
                        item.IsExpanded = true;
                    }
                }
            }
        }

This is working fine Expand all groups at first time, but when i select the specific item from grid and edit it through dialogue box, on closed the dialogue box i get again all the record from database when assign to xamgrid collection who already bind it, collection are updated and also grid groups are collapsed and my selected row was unselect. 

                AddEditIndicators view = new AddEditIndicators();
                AddEditIndicatorsViewModel vm = new AddEditIndicatorsViewModel(_selectedIndicator);
                vm.RequestViewClose += (sndr, evt) => { view.Close(); };
                view.DataContext = vm;
                view.Closed += (s, a) =>
                {
                    this.InterpolatedIndicators = InterpolatedIndicatorFieldInfo.GetAll(false, false);
                };
                view.Owner = ((App)App.Current).AppMainWindow;
                view.ShowDialog();

        private List<InterpolatedIndicatorFieldInfo> _lstIndicators;
        public List<InterpolatedIndicatorFieldInfo> InterpolatedIndicators
        {
            get { return _lstIndicators; }
            set
            {
                _lstIndicators = value;
                OnPropertyChanged("InterpolatedIndicators");
            }
        }

InterpolatedIndicators collection is bind with grid. AddEditIndicators is a view used for edit the record.