예제 #1
0
        protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            base.OnPropertyChanged(e);

            if (e.Property == RowSelector.DataContextProperty)
            {
                Type rowType = null;

                Row row = this.DataContext as Row;
                if (row != null)
                {
                    rowType = row.GetType();
                }
                else
                {
                    HeaderFooterItem hfi = this.DataContext as HeaderFooterItem;
                    if (hfi != null)
                    {
                        row = hfi.AsVisual() as Row;
                        if (row != null)
                        {
                            rowType = row.GetType();
                        }
                    }
                }

                this.SetRowType(rowType);
            }
        }
예제 #2
0
        private static bool IsContainerQualifying(
            FrameworkElement container,
            DataGridControl gridControl,
            double offset,
            double viewportSize,
            double opposedOffset,
            double opposedViewportSize,
            Orientation panelOrientation)
        {
            bool retval = true;

            HeaderFooterItem headerFooterItemContainer = container as HeaderFooterItem;
            Row rowContainer = container as Row;

            //Determine if the Element is Focusable or Navigable
            if (headerFooterItemContainer != null)
            {
                rowContainer = headerFooterItemContainer.AsVisual() as Row;
                if (rowContainer == null)
                {
                    //If the HeaderFooter Item is not a Row and is Not focusable, then the item does not qualify.
                    UIElement uiElementContainer = headerFooterItemContainer.AsVisual() as UIElement;
                    if ((uiElementContainer == null) || (!uiElementContainer.Focusable))
                    {
                        retval = false;
                    }
                }
            }

            //If the container is a Row (in the headers footers region or not )
            if ((retval) && (rowContainer != null))
            {
                //and the Row is not navigable, then it does not qualify.
                if (rowContainer.NavigationBehavior == NavigationBehavior.None)
                {
                    retval = false;
                }
            }


            //If the container still qualifies after first verification, check for the scrolling axis.
            if (retval)
            {
                //if the PrimaryAxis requires the opposed axis to be fully visible.
                if (((panelOrientation == Orientation.Vertical) && ((gridControl.ItemsPrimaryAxis == PrimaryAxis.Horizontal) || (gridControl.ItemsPrimaryAxis == PrimaryAxis.Both))) ||
                    ((panelOrientation == Orientation.Horizontal) && ((gridControl.ItemsPrimaryAxis == PrimaryAxis.Vertical) || (gridControl.ItemsPrimaryAxis == PrimaryAxis.Both))))
                {
                    FrameworkElement frameworkElementContainer = container as FrameworkElement;
                    //Somehow, I decided that a container that is not a FrameworkElement (extremelly highly unprobable) was automaticaly NOT to qualify if opposed axis was required.
                    if (frameworkElementContainer != null)
                    {
                        Vector rowOffset = VisualTreeHelper.GetOffset(frameworkElementContainer);

                        double computedOffset = (panelOrientation == Orientation.Vertical) ? rowOffset.X : rowOffset.Y;
                        double computedSize   = (panelOrientation == Orientation.Vertical) ? frameworkElementContainer.ActualWidth : frameworkElementContainer.ActualHeight;

                        //if the coordinates of the Row are NOT inside the Scrolling Axis' viewport... then the item is not qualifyable.
                        if ((computedOffset < opposedOffset) || ((computedOffset + computedSize) > (opposedViewportSize + opposedOffset)))
                        {
                            retval = false;
                        }
                    }
                    else
                    {
                        retval = false;
                    }
                }
            }

            return(retval);
        }