private static bool SetFixedTranslateTransformCore(FrameworkElement element, bool canScrollHorizontally)
        {
            Debug.Assert(element != null);

            var parentScrollViewer = TableViewScrollViewer.GetParentScrollViewer(element) as ScrollViewer;

            if (parentScrollViewer == null)
            {
                return(false);
            }

            var fixedTransform = TableViewScrollViewer.GetStoredFixedTransform(parentScrollViewer);

            Debug.Assert(fixedTransform != null);

            if (canScrollHorizontally)
            {
                if (element.RenderTransform == fixedTransform)
                {
                    element.ClearValue(UIElement.RenderTransformProperty);
                }
            }
            else
            {
                element.RenderTransform = fixedTransform;
            }

            return(true);
        }
示例#2
0
        private static void OnCanScrollHorizontallyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            // This property makes sense (only works) for potentially visible element; UIElement.
            var element = sender as FrameworkElement;

            if (element == null)
            {
                return;
            }

            TableViewScrollViewer.SetFixedTranslateTransform(element, ( bool )e.NewValue);
        }
        internal static Transform GetStoredFixedTransform(ScrollViewer obj)
        {
            Transform actualValue = ( Transform )obj.GetValue(TableViewScrollViewer.StoredFixedTransformProperty);

            if (actualValue == null)
            {
                actualValue = TableViewScrollViewer.CreateFixedPanelTransform(obj);
                TableViewScrollViewer.SetStoredFixedTransform(obj, actualValue);
            }

            return(actualValue);
        }
        private static void OnFixedElementLoaded(object sender, RoutedEventArgs e)
        {
            var element = sender as FrameworkElement;

            if (element == null)
            {
                return;
            }

            element.Loaded -= new RoutedEventHandler(TableViewScrollViewer.OnFixedElementLoaded);

            TableViewScrollViewer.SetFixedTranslateTransformCore(element, TableView.GetCanScrollHorizontally(element));
        }
        internal static TableViewScrollViewer GetParentTableViewScrollViewer(DependencyObject obj)
        {
            DependencyObject      parent             = TreeHelper.GetParent(obj);
            TableViewScrollViewer parentScrollViewer = parent as TableViewScrollViewer;

            while ((parent != null) && (parentScrollViewer == null))
            {
                parent             = TreeHelper.GetParent(parent);
                parentScrollViewer = parent as TableViewScrollViewer;
            }

            return(parentScrollViewer);
        }
        internal static void SetFixedTranslateTransform(FrameworkElement element, bool canScrollHorizontally)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            if (!TableViewScrollViewer.SetFixedTranslateTransformCore(element, canScrollHorizontally))
            {
                if (!element.IsLoaded)
                {
                    // The method failed to apply the translate transform because it could not find a ScrollViewer
                    // among its ancestors.  Try again when the element will be loaded in case it wasn't in the
                    // VisualTree.
                    element.Loaded += new RoutedEventHandler(TableViewScrollViewer.OnFixedElementLoaded);
                }
            }
        }
示例#7
0
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            Size finalSize = base.ArrangeOverride(arrangeSize);

            DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

            DataGridControl dataGridControl = (dataGridContext != null)
        ? dataGridContext.DataGridControl
        : null;

            RowSelectorPane rowSelectorPane = null;

            // dataGridControl can be null in design-time
            if (dataGridControl != null)
            {
                TableViewScrollViewer scrollViewer = dataGridControl.ScrollViewer as TableViewScrollViewer;
                rowSelectorPane = (scrollViewer != null) ? scrollViewer.RowSelectorPane : null;
            }

            if (rowSelectorPane == null)
            {
                return(finalSize);
            }

            Visibility rowSelectorPaneVisibility = ( Visibility )rowSelectorPane.GetValue(RowSelectorPane.VisibilityProperty);

            if (rowSelectorPaneVisibility != Visibility.Visible)
            {
                return(finalSize);
            }

            foreach (UIElement child in this.InternalChildren)
            {
                Vector offset      = VisualTreeHelper.GetOffset(child);
                Size   desiredSize = child.DesiredSize;

                rowSelectorPane.SetRowSelectorPosition(child, new Rect(offset.X, offset.Y, desiredSize.Width, desiredSize.Height), this);
            }

            return(finalSize);
        }
示例#8
0
        private void UpdateChildScrollViewers()
        {
            bool isAtTop    = (this.VerticalOffset == 0);
            bool isAtLeft   = (this.HorizontalOffset == 0);
            bool isAtBottom = ((this.VerticalOffset + this.ViewportHeight) == this.ExtentHeight);
            bool isAtRight  = ((this.HorizontalOffset + this.ViewportWidth) == this.ExtentWidth);

            foreach (SynchronizedScrollViewer scrollViewer in m_childScrollViewers)
            {
                SynchronizedScrollViewerPosition position = TableViewScrollViewer.GetSynchronizedScrollViewerPosition(scrollViewer);

                bool handled = false;

                switch (position)
                {
                case SynchronizedScrollViewerPosition.Top:
                    if (isAtTop == true)
                    {
                        KeyboardNavigation.SetDirectionalNavigation(scrollViewer, KeyboardNavigationMode.Continue);
                        KeyboardNavigation.SetTabNavigation(scrollViewer, KeyboardNavigationMode.Continue);
                        handled = true;
                    }
                    break;

                case SynchronizedScrollViewerPosition.Bottom:
                    if (isAtBottom == true)
                    {
                        KeyboardNavigation.SetDirectionalNavigation(scrollViewer, KeyboardNavigationMode.Continue);
                        KeyboardNavigation.SetTabNavigation(scrollViewer, KeyboardNavigationMode.Continue);
                        handled = true;
                    }
                    break;

                case SynchronizedScrollViewerPosition.Left:
                    if (isAtLeft == true)
                    {
                        KeyboardNavigation.SetDirectionalNavigation(scrollViewer, KeyboardNavigationMode.Continue);
                        KeyboardNavigation.SetTabNavigation(scrollViewer, KeyboardNavigationMode.Continue);
                        handled = true;
                    }
                    break;

                case SynchronizedScrollViewerPosition.Right:
                    if (isAtRight == true)
                    {
                        KeyboardNavigation.SetDirectionalNavigation(scrollViewer, KeyboardNavigationMode.Continue);
                        KeyboardNavigation.SetTabNavigation(scrollViewer, KeyboardNavigationMode.Continue);
                        handled = true;
                    }
                    break;

                case SynchronizedScrollViewerPosition.None:
                default:
                    break;
                }

                if (handled == false)
                {
                    KeyboardNavigation.SetDirectionalNavigation(scrollViewer, KeyboardNavigationMode.None);
                    KeyboardNavigation.SetTabNavigation(scrollViewer, KeyboardNavigationMode.None);
                }
            }
        }