Beispiel #1
0
        protected override Size MeasureOverride(Size availableSize)
        {
            Panel panel = this.GroupLevelIndicatorPaneHost;

            if (panel != null)
            {
                DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

                if (dataGridContext != null)
                {
                    if (this.GroupLevelIndicatorPaneNeedsRefresh)
                    {
                        //clear all the panel's children!
                        panel.Children.Clear();

                        DataGridContext previousContext        = dataGridContext;
                        DataGridContext runningDataGridContext = dataGridContext.ParentDataGridContext;

                        while (runningDataGridContext != null)
                        {
                            //create a GroupLevelIndicator to create indentation between the GLIPs
                            FrameworkElement newGroupMargin = null;
                            newGroupMargin             = new DetailIndicator();
                            newGroupMargin.DataContext = dataGridContext;

                            object bindingSource = dataGridContext.GetDefaultDetailConfigurationForContext();
                            if (bindingSource == null)
                            {
                                bindingSource = dataGridContext.SourceDetailConfiguration;
                            }

                            //Bind the GroupLevelIndicator`s style to the running DataGridContext`s GroupLevelIndicatorStyle.
                            Binding groupLevelIndicatorStyleBinding = new Binding();
                            groupLevelIndicatorStyleBinding.Path   = new PropertyPath(DetailConfiguration.DetailIndicatorStyleProperty);
                            groupLevelIndicatorStyleBinding.Source = bindingSource;
                            newGroupMargin.SetBinding(StyleProperty, groupLevelIndicatorStyleBinding);

                            //insert the Spacer GroupLevelIndicator in the panel
                            panel.Children.Insert(0, newGroupMargin);

                            //then create the GLIP for the running DataGridContext
                            GroupLevelIndicatorPane newSubGLIP = new GroupLevelIndicatorPane();
                            DataGridControl.SetDataGridContext(newSubGLIP, runningDataGridContext);
                            newSubGLIP.SetIsLeaf(false);
                            GroupLevelIndicatorPane.SetGroupLevel(newSubGLIP, -1);

                            //and insert it in the panel.
                            panel.Children.Insert(0, newSubGLIP);

                            previousContext        = runningDataGridContext;
                            runningDataGridContext = runningDataGridContext.ParentDataGridContext;
                        } //end of the loop to cycle through the parent contexts.
                    }     // end if GroupLevelIndicatorPaneNeedsRefresh
                }         // end if dataGridContext != null
            }             //end if panel is not null

            return(base.MeasureOverride(availableSize));
        }