Exemple #1
0
        private static void IsInSelectionRange(UIElement uiElement)
        {
            if (_test != FindParentItemsControl(uiElement))
            {
                return;
            }

            var columnContentPresenter = VisualTreeExtensions.FindAncestor <ContentPresenter>(uiElement);
            var columnUniformGrid      = VisualTreeExtensions.FindAncestor <UniformGrid>(columnContentPresenter);

            var rowContentPresenter = VisualTreeExtensions.FindAncestor <ContentPresenter>(columnUniformGrid);
            var rowUniformGrid      = VisualTreeExtensions.FindAncestor <UniformGrid>(rowContentPresenter);

            for (int i = 0; i < rowUniformGrid.Children.Count; i++)
            {
                var item = VisualTreeExtensions.FindChild <UniformGrid>(rowUniformGrid.Children[i]);

                for (int j = 0; j < item.Children.Count; j++)
                {
                    var grid = VisualTreeExtensions.FindChild <Grid>(item.Children[j]);
                    if (j >= SelectionRangeColumnStart && j <= SelectionRangeColumnEnd && i >= SelectionRangeRowStart && i <= SelectionRangeRowEnd)
                    {
                        SetIsSelected(grid, true);
                    }
                    else
                    {
                        SetIsSelected(grid, false);
                    }
                }
            }
        }
Exemple #2
0
        private static (int Row, int Column) GetControlPositionInGrid(UIElement uiElement)
        {
            var columnContentPresenter = VisualTreeExtensions.FindAncestor <ContentPresenter>(uiElement);
            var columnUniformGrid      = VisualTreeExtensions.FindAncestor <UniformGrid>(columnContentPresenter);
            var column = columnUniformGrid.Children.IndexOf(columnContentPresenter);

            var rowContentPresenter = VisualTreeExtensions.FindAncestor <ContentPresenter>(columnUniformGrid);
            var rowUniformGrid      = VisualTreeExtensions.FindAncestor <UniformGrid>(rowContentPresenter);
            var row = rowUniformGrid.Children.IndexOf(rowContentPresenter);

            return(row, column);
        }
Exemple #3
0
        private static void ForceDeselect(UIElement uiElement)
        {
            var rowUniformGrid = VisualTreeExtensions.FindChild <UniformGrid>(uiElement);

            for (int i = 0; i < rowUniformGrid.Children.Count; i++)
            {
                var item = VisualTreeExtensions.FindChild <UniformGrid>(rowUniformGrid.Children[i]);

                for (int j = 0; j < item.Children.Count; j++)
                {
                    var grid = VisualTreeExtensions.FindChild <Grid>(item.Children[j]);
                    SetIsSelected(grid, false);
                }
            }
        }
Exemple #4
0
        private static ItemsControl FindParentItemsControl(UIElement uiElement)
        {
            var first = VisualTreeExtensions.FindAncestor <ItemsControl>(uiElement);

            return(VisualTreeExtensions.FindAncestor <ItemsControl>(first));
        }