Ejemplo n.º 1
0
 public void ChildRemove(object o)
 {
     ColumnGroups.Remove(o as ColumnGroup);
 }
Ejemplo n.º 2
0
        //If the user selects a column option.  We need to perform the operation
        private void optionCtrl_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var optionCtrl = sender as ColumnOptionControl;

            if (e.PropertyName == "SelectedColumnOptionItem")
            {
                if (optionCtrl != null)
                {
                    switch (optionCtrl.SelectedColumnOptionItem.ColumnOption)
                    {
                    case Enums.ColumnOption.AddGrouping:
                        optionCtrl.IsGrouped = true;
                        var v = new PagedCollectionView(FilteredItemsSource);

                        var newGroup = new PropertyGroupDescription(optionCtrl.FilterColumnInfo.PropertyPath, optionCtrl.FilterColumnInfo.Converter);
                        ColumnGroups.Add(newGroup);

                        foreach (var item in ColumnGroups)
                        {
                            v.GroupDescriptions.Add(item);
                        }

                        ItemsSource = v;
                        break;

                    case Enums.ColumnOption.RemoveGrouping:
                        optionCtrl.IsGrouped = false;
                        var view  = new PagedCollectionView(FilteredItemsSource);
                        var group = ColumnGroups.FirstOrDefault(c => c.PropertyName == optionCtrl.FilterColumnInfo.PropertyPath);
                        if (@group != null)
                        {
                            ColumnGroups.Remove(@group);
                        }
                        foreach (var item in ColumnGroups)
                        {
                            view.GroupDescriptions.Add(item);
                        }
                        ItemsSource = view;
                        break;

                    case Enums.ColumnOption.PinColumn:
                        optionCtrl.IsPinned = true;
                        var frozenCount = FrozenColumnCount;
                        if (optionCtrl.Column.DisplayIndex >= FrozenColumnCount)
                        {
                            frozenCount++;
                        }
                        optionCtrl.Column.DisplayIndex = 0;
                        FrozenColumnCount = frozenCount;
                        break;

                    case Enums.ColumnOption.UnpinColumn:
                        optionCtrl.IsPinned = false;
                        if (FrozenColumnCount == 0)
                        {
                            FrozenColumnCount = 1;
                        }
                        optionCtrl.Column.DisplayIndex = FrozenColumnCount - 1;
                        FrozenColumnCount = FrozenColumnCount - 1;
                        break;
                    }
                }
            }
        }