Ejemplo n.º 1
0
        private static int CompareColumnNames(
            AsyncDataGridColumn lhs, AsyncDataGridColumn rhs)
        {
            var comparisonType = StringComparison.CurrentCultureIgnoreCase;

            int cmp = string.Compare(lhs.ColumnName, rhs.ColumnName, comparisonType);

            if (cmp != 0)
            {
                return(cmp);
            }

            return(lhs.ModelVisibleColumnIndex.CompareTo(rhs.ModelVisibleColumnIndex));
        }
Ejemplo n.º 2
0
        private MenuItem CreateContainer(AsyncDataGridColumn column)
        {
            var item = new MenuItem {
                IsCheckable      = true,
                StaysOpenOnClick = true,
                DataContext      = column
            };

            item.SetBinding(MenuItem.IsCheckedProperty, new Binding(nameof(column.IsVisible))
            {
                Mode = BindingMode.TwoWay
            });
            item.SetBinding(HeaderedItemsControl.HeaderProperty, new Binding(nameof(column.ColumnName))
            {
                Mode = BindingMode.OneWay
            });
            return(item);
        }
Ejemplo n.º 3
0
        internal double GetColumnAutoSize(AsyncDataGridColumn column)
        {
            if (!column.IsVisible && !column.IsDisconnected)
            {
                throw new InvalidOperationException();
            }

            double width = 5.0;

            var viewModel = cellsPresenter.ViewModel;

            if (viewModel == null || viewModel.RowCount <= 0)
            {
                return(width);
            }

            double        rowHeight       = cellsPresenter.RowHeight;
            int           firstVisibleRow = cellsPresenter.FirstVisibleRowIndex;
            int           lastVisibleRow  = cellsPresenter.LastVisibleRowIndex;
            Typeface      typeface        = cellsPresenter.Typeface;
            double        fontSize        = cellsPresenter.FontSize;
            Brush         foreground      = cellsPresenter.Foreground;
            FlowDirection flowDirection   = cellsPresenter.FlowDirection;
            CultureInfo   currentCulture  = CultureInfo.CurrentCulture;

            double padding          = rowHeight / 10;
            double totalPadding     = 2 * padding;
            int    viewportSizeHint = lastVisibleRow - firstVisibleRow + 1;

            for (int row = firstVisibleRow; row <= lastVisibleRow; ++row)
            {
                var value     = column.GetCellValue(row, viewportSizeHint);
                var formatted = new FormattedText(
                    value.ToString(), currentCulture, flowDirection, typeface,
                    fontSize, foreground, null, TextFormattingMode.Display);

                width = Math.Max(width, formatted.Width + totalPadding + 1);
            }

            return(width);
        }
Ejemplo n.º 4
0
 public AsyncDataGridColumnReorderingEventArgs(
     AsyncDataGridColumn column)
     : base(column)
 {
 }
Ejemplo n.º 5
0
 public AsyncDataGridColumnEventArgs(AsyncDataGridColumn column)
 {
     Column = column;
 }