// bind cell to ticker
        public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange range)
        {
            // create binding for this cell
            var r = grid.Rows[range.Row];
            var c = grid.Columns[range.Column];
            var pi = c.PropertyInfo;
            if (r.DataItem is FinancialData &&
               (pi.Name == "LastSale" || pi.Name == "Bid" || pi.Name == "Ask"))
            {
                // create stock ticker cell
                StockTicker ticker = new StockTicker();
                bdr.Child = ticker;
                bdr.Padding = _thicknessEmpty;

                // to show sparklines
                ticker.Tag = r.DataItem;
                ticker.BindingSource = pi.Name;

                // traditional binding
                var binding = new Binding(pi.Name);
                binding.Source = r.DataItem;
                binding.Mode = BindingMode.OneWay;
                ticker.SetBinding(StockTicker.ValueProperty, binding);
            }
            else
            {
                // use default implementation
                base.CreateCellContent(grid, bdr, range);
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            var flex = new C1FlexGrid();
            flex.CellFactory = new ConditionalFormattingFactory();
            LayoutRoot.Children.Add(flex);

            var list = Product.GetProducts(100);

            foreach (var pi in typeof(Product).GetProperties())
            {
                var c = new Column();
                c.Header = pi.Name;
                c.DataType = pi.PropertyType;
                if (pi.PropertyType == typeof(double))
                {
                    c.Format = "n0";
                }
                flex.Columns.Add(c);
            }

            foreach (var p in list)
            {
                var r = new Row();
                flex.Rows.Add(r);
                foreach (var c in flex.Columns)
                {
                    var pi = typeof(Product).GetProperty(c.Header);
                    r[c] = pi.GetValue(p, null);
                }
            }
        }
        // customize cells
        public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange rng)
        {
            // attach grid event handlers
            SetGrid(grid);

            // get the row/column being created
            var col = grid.Columns[rng.Column];
            var row = grid.Rows[rng.Row];
            var field = row.DataItem as FormField;
            var gr = row as GroupRow;

            // create the cell
            base.CreateCellContent(grid, bdr, rng);
            if (col.BoundPropertyName == "Value" && gr == null)
            {
                if (!string.IsNullOrEmpty(field.Formula))
                {
                    _calculatedStyle.Apply(bdr, SelectedState.None);
                }
                else
                {
                    _editStyle.Apply(bdr, SelectedState.None);
                    if (!field.IsString)
                    {
                        _numberStyle.Apply(bdr, SelectedState.None);
                    }
                }
            }
        }
 internal MouseHandler(C1FlexGrid grid)
 {
     _grid = grid;
     CellRange empty = CellRange.Empty;
     CellRange cellRange = empty;
     _dragTarget = empty;
     _cellResize = cellRange;
     _tmScroll = new Timer();
     _tmScroll.Tick += OnDragTimerTick;
     _tmScroll.Interval = TimeSpan.FromMilliseconds(SCROLL_DELAY);
     _dragHelper = new C1DragHelper(_grid,
         C1DragHelperMode.TranslateX | C1DragHelperMode.TranslateY | C1DragHelperMode.TranslateXY | C1DragHelperMode.Inertia | C1DragHelperMode.TranslateRailX |
         C1DragHelperMode.TranslateRailY, 1, false, false, false, false);
     _dragHelper.DragStarting += OnDragStarting;
     _dragHelper.DragStarted += OnDragStarted;
     _dragHelper.DragDelta += OnDragDelta;
     _dragHelper.DragCompleted += OnDragCompleted;
     _dragHelper.DragInertiaStarted += OnDragInertiaStarted;
     C1TapHelper c1TapHelper = new C1TapHelper(_grid, false);
     c1TapHelper.Tapped += OnTapped;
     c1TapHelper.DoubleTapped += OnDoubleTapped;
     _grid.KeyDown += OnKeyDown;
     _grid.MouseWheel += OnWheelChanged;
     _grid.MouseMove += OnMouseMove;
     _grid.AddHandler(UIElement.MouseLeftButtonUpEvent, new MouseButtonEventHandler(OnMouseLeftButtonUp), true);
     _grid.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(OnMouseLeftButtonDown), true);
 }
 /// <summary>
 ///     Gets a <see cref="T:C1.WPF.FlexGrid.CellRange" /> that specifies the merged extent of a cell
 ///     in a <see cref="T:C1.WPF.FlexGrid.GridPanel" />.
 /// </summary>
 /// <param name="grid">
 ///     <see cref="T:C1.WPF.FlexGrid.C1FlexGrid" /> that contains the merged cell.
 /// </param>
 /// <param name="cellType">
 ///     <see cref="T:C1.WPF.FlexGrid.CellType" /> that specifies the type of the merged cell.
 /// </param>
 /// <param name="rng">A <see cref="T:C1.WPF.FlexGrid.CellRange" /> that specifies the coordinates of the cell to be merged.</param>
 /// <returns>
 ///     A <see cref="T:C1.WPF.FlexGrid.CellRange" /> that expands the given <paramref name="rng" /> over a merged
 ///     range.
 /// </returns>
 /// <remarks>
 ///     This method expands ranges by comparing the cell contents with the content of neighboring
 ///     cells and merging cells that have the same content.
 /// </remarks>
 public virtual CellRange GetMergedRange(C1FlexGrid grid, CellType cellType, CellRange rng)
 {
     switch (cellType)
     {
         case CellType.Cell:
         {
             if (grid.ActiveEditor != null && grid.EditorRange.Contains(rng))
             {
                 return grid.EditorRange;
             }
             if (grid.GetChildItemsPropertyInfo() != null)
             {
                 return rng;
             }
             return GetMergedRange(grid, grid.Cells, rng);
         }
         case CellType.ColumnHeader:
         {
             return GetMergedRange(grid, grid.ColumnHeaders, rng);
         }
         case CellType.RowHeader:
         {
             return GetMergedRange(grid, grid.RowHeaders, rng);
         }
         case CellType.TopLeft:
         {
             return GetMergedRange(grid, grid.TopLeftCells, rng);
         }
     }
     return rng;
 }
        public override void CreateColumnHeaderContent(C1FlexGrid grid, Border bdr, CellRange range)
        {
            base.CreateColumnHeaderContent(grid, bdr, range);

            //var row = grid.Rows[range.Row];
            //var column = grid.Columns[range.Column];
            //var propertyInfo = column.PropertyInfo;

            //CustomColumnHeader header =new CustomColumnHeader();


            //Binding nameBinding = new Binding();
            //nameBinding.Path = new PropertyPath("HeaderName");
            //header.SetBinding(CustomColumnHeader.HeaderNameProperty, nameBinding);

            //Binding tooltipBinding = new Binding();
            //tooltipBinding.Path = new PropertyPath("HeaderName");
            //header.SetBinding(CustomColumnHeader.HeaderTooltipProperty, tooltipBinding);


            //bdr.Child = header;
            //bdr.Padding = _thicknessEmpty;
            //bdr.HorizontalAlignment = HorizontalAlignment.Stretch;

            //header.HeaderName = propertyInfo.Name;
            //header.HeaderToolTip = propertyInfo.Name;

            //// traditional binding
            //var binding = new Binding(propertyInfo.Name);
            //binding.Source = grid.ColumnHeaders;
            //binding.Mode = BindingMode.OneWay;
            //header.SetBinding(CustomColumnHeader.HeaderNameProperty, binding);
        }
        public CellRange GetMergedRange(C1FlexGrid grid, CellType cellType, CellRange rg)
        {
            // we are only interested in data cells
            // (not merging row or column headers)
            if (cellType == CellType.Cell)
            {
                // expand left/right
                for (int i = rg.Column; i < grid.Columns.Count - 1; i++)
                {
                    if (GetDataDisplay(grid, rg.Row, i) != GetDataDisplay(grid, rg.Row, i + 1)) break;
                    rg.Column2 = i + 1;
                }
                for (int i = rg.Column; i > 0; i--)
                {
                    if (GetDataDisplay(grid, rg.Row, i) != GetDataDisplay(grid, rg.Row, i - 1)) break;
                    rg.Column = i - 1;
                }

                // expand up/down
                for (int i = rg.Row; i < grid.Rows.Count - 1; i++)
                {
                    if (GetDataDisplay(grid, i, rg.Column) != GetDataDisplay(grid, i + 1, rg.Column)) break;
                    rg.Row2 = i + 1;
                }
                for (int i = rg.Row; i > 0; i--)
                {
                    if (GetDataDisplay(grid, i, rg.Column) != GetDataDisplay(grid, i - 1, rg.Column)) break;
                    rg.Row = i - 1;
                }
            }

            // done
            return rg;
        }
        // look for a row that contains some text in a specific column
        int FindRow(C1FlexGrid flex, string text, int startRow, int col, bool wrap)
        {
            int count = flex.Rows.Count;
            for (int off = 0; off <= count; off++)
            {
                // reached the bottom and not wrapping? quit now
                if (!wrap && startRow + off >= count)
                {
                    break;
                }

                // get text from row
                int row = (startRow + off) % count;
                var content = flex[row, col];

                // found? return row index
                if (content != null &&
                    content.ToString().IndexOf(text, StringComparison.OrdinalIgnoreCase) > -1)
                {
                    return row;
                }
            }

            // not found...
            return -1;
        }
 public override void CreateColumnHeaderContent(C1FlexGrid grid, Border bdr, CellRange range)
 {
     var tb = new TextBlock();
     tb.HorizontalAlignment = HorizontalAlignment.Center;
     tb.VerticalAlignment = VerticalAlignment.Center;
     tb.Text = GetAlphaColumnHeader(range.Column);
     bdr.Child = tb;
 }
 // override horizontal alignment to make ticker cell stretch and fill the column width
 public override void ApplyCellStyles(C1FlexGrid grid, CellType cellType, CellRange range, Border bdr)
 {
     var ticker = bdr.Child as StockTicker;
     if (ticker != null)
     {
         ticker.HorizontalAlignment = HorizontalAlignment.Stretch;
     }
 }
 public override void CreateRowHeaderContent(C1FlexGrid grid, Border bdr, CellRange range)
 {
     var tb = new TextBlock();
     tb.HorizontalAlignment = HorizontalAlignment.Center;
     tb.VerticalAlignment = VerticalAlignment.Center;
     tb.Text = string.Format("{0}", range.Row + 1);
     bdr.Child = tb;
 }
 public FilterCellFactory(C1FlexGridFilter filter, C1FlexGrid flex)
 {
     _flex = flex;
     _gridFilter = filter;
     _baseCellFactory = flex.GetCellFactory();
     _flex.SizeChanged += _flex_ScrollPositionChanging;
     _flex.ScrollPositionChanging += _flex_ScrollPositionChanging;
     Editor = new ColumnFilterEditor();
 }
 /// <summary>
 /// Initializes a new instance of an <see cref="CellRangeEditAction"/>.
 /// </summary>
 public CellRangeEditAction(C1FlexGrid flex)
 {
     _flex = flex;
     var sel = _flex.Selection;
     _oldTopRow = sel.TopRow;
     _oldLeftCol = sel.LeftColumn;
     _oldSelection = sel;
     RecordState(ref _oldCellValues, sel);
 }
 /// <summary>
 /// Initializes a new instance of an <see cref="ExcelCellFactory"/>.
 /// </summary>
 /// <param name="flex"><see cref="C1FlexGrid"/> that owns this cell factory.</param>
 public ExcelCellFactory(C1FlexGrid flex)
 {
     _flex = flex;
     if (_styleRight == null)
     {
         _styleRight = new CellStyle();
         _styleRight.HorizontalAlignment = HorizontalAlignment.Right;
     }
 }
        /// <summary>
        /// Applies custom styles to the outline row.
        /// </summary>
        public override void ApplyCellStyles(C1FlexGrid grid, CellType cellType, CellRange range, Border bdr)
        {
            if (cellType == CellType.Cell)
            {
                bool hasAlignment = false;

                // get selection state for the range
                var selState = grid.GetSelectedState(range);

                // apply row style
                var row = grid.Rows[range.Row];
                if (row.CellStyle != null)
                {
                    row.CellStyle.Apply(bdr, selState);
                    hasAlignment |= row.CellStyle.HorizontalAlignment.HasValue;
                }

                // apply column style
                var col = grid.Columns[range.Column];
                if (col.CellStyle != null)
                {
                    col.CellStyle.Apply(bdr, selState);
                    hasAlignment |= col.CellStyle.HorizontalAlignment.HasValue;
                }

                // apply cell style
                var xlr = row as ExcelRow;
                if (xlr != null)
                {
                    var s = xlr.GetCellStyle(col);
                    if (s != null)
                    {
                        // leave hyperlink foreground alone...
                        if (bdr.Child is HyperlinkButton)
                        {
                            s.Foreground = null;
                        }

                        // apply standard CellStyle stuff
                        s.Apply(bdr, selState);
                        hasAlignment |= s.HorizontalAlignment.HasValue;

                        // apply general alignment
                        if (!hasAlignment)
                        {
                            var content = grid[range.Row, range.Column];
                            if (IsNumeric(content))
                            {
                                _styleRight.Apply(bdr, selState);
                            }
                        }
                    }
                }
            }
        }
 public override void CreateTopLeftContent(C1FlexGrid grid, Border bdr, CellRange range)
 {
     var poly = CreatePolygon(0, 10, 10, 10, 10, 0);
     poly.Fill = new SolidColorBrush(Color.FromArgb(0xe0, 0xf5, 0xf5, 0xf5));
     poly.VerticalAlignment = VerticalAlignment.Center;
     poly.HorizontalAlignment = HorizontalAlignment.Right;
     poly.Margin = new Thickness(2);
     bdr.Child = poly;
     bdr.Tag = grid;
     bdr.MouseLeftButtonDown += new MouseButtonEventHandler(bdr_MouseLeftButtonDown);
 }
Exemple #17
0
 internal GridPanel(C1FlexGrid grid, CellType cellType, int rowHeight, int colWidth)
 {
     Grid = grid;
     CellType = cellType;
     _cells = new CellRangeDictionary();
     ViewRange = CellRange.Empty;
     Rows = new RowCollection(this, rowHeight);
     Columns = new ColumnCollection(this, colWidth);
     HorizontalAlignment = HorizontalAlignment.Left;
     VerticalAlignment = VerticalAlignment.Top;
 }
        public void Save(string filename, C1FlexGrid flexgrid)
        {
            // create the book to save
            var book = new C1XLBook();
            book.Sheets.Clear();
            var  xlSheet = book.Sheets.Add("Sheet1");
            ExcelExport.ExcelFilter.Save(flexgrid, xlSheet);

            // save the book
            book.Save(filename, C1.WPF.Excel.FileFormat.OpenXml);
        }
        // create group row to show column footer cells
        // NOTE:
        //   using a group row because that is read-only and provides
        //   automatic aggregates when the column's GroupAggregate
        //   property is set.
        void AddColumnFooter(C1.WPF.FlexGrid.C1FlexGrid flex)
        {
            flex.ColumnFooters.Columns.Add(new Column());
            var gr = new C1.WPF.FlexGrid.GroupRow();

            // customize appearance of the new row
            gr.FontWeight = FontWeights.Bold;
            gr.Background = new SolidColorBrush(Color.FromArgb(0xff, 0x80, 0x00, 0x00));
            gr.Foreground = new SolidColorBrush(Colors.White);
            // add the row to the ColumnFooters GridPanel
            flex.ColumnFooters.Rows.Add(gr);
            gr[0] = "Totals";
        }
 public override FrameworkElement CreateCell(C1FlexGrid grid, CellType cellType, CellRange rng)
 {
     FrameworkElement frameworkElement = _baseCellFactory.CreateCell(grid, cellType, rng);
     if (cellType == CellType.ColumnHeader)
     {
         Border border = frameworkElement as Border;
         if (border != null)
         {
             CreateColumnHeaderContent(grid, border, rng);
         }
     }
     return frameworkElement;
 }
        public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange rng)
        {
            // crate the content
            base.CreateCellContent(grid, bdr, rng);

            // add the tooltip
            var tip = string.Format("row: {0} col: {1}\r\ncontent: {2}\r\ncolumn Tag: {3}",
                rng.Row,
                rng.Column,
                grid[rng.Row, rng.Column],
                grid.Columns[rng.Column].Tag);
            ToolTipService.SetToolTip(bdr, tip);
        }
        /// <summary>
        /// Initializes a new instance of a <see cref="DropDownProvider"/>.
        /// </summary>
        public DropDownProvider(MultiColumnComboBox cb)
        {
            // hook up to parent control
            _cb = cb;
            _cb.TextChanged += _cbTextChanged;
            _cb.LostFocus += _cbLostFocus;
            _cb.PreviewKeyDown += _cbKeyDown;

            // initialize dropdown
            _flex = new C1FlexGrid();
            _flex.LostFocus += _cbLostFocus;
            _flex.SelectionChanged += _flex_SelectionChanged;
            UpdateGridLayout();
        }
 // create the custom cell editor
 public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange rng)
 {
     var t = GetCellType(rng);
     if (t != null)
     {
         // cell has a custom type, create editor
         bdr.Child = CreateEditor(t, rng);
     }
     else
     {
         // default handling
         base.CreateCellContent(grid, bdr, rng);
     }
 }
        public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange rng)
        {
            base.CreateCellContent(grid, bdr, rng);

            var row = grid.Rows[rng.Row] as GroupRow;
            if (rng.Column == 0 && row != null)
            {
                bdr.Padding = _tEmpty;
                var cellGrid = bdr.Child as Grid;
                cellGrid.Children.RemoveAt(0);
                var treeNode = CreateTreeNode(grid, row);
                cellGrid.Children.Add(treeNode);
            }
        }
        // ** IMergeManager
        public CellRange GetMergedRange(C1FlexGrid grid, CellType cellType, CellRange range)
        {
            // look for merged ranges that contain the given cell
            foreach (var mergedRange in _mergedRanges)
            {
                if (mergedRange.Contains(range))
                {
                    return mergedRange;
                }
            }

            // not found, not merged
            return range;
        }
        public FlexPaginator(C1FlexGrid flex, ScaleMode scaleMode, Size pageSize, Thickness margin, int maxPages)
        {
            // save parameters
            _margin = margin;
            _scaleMode = scaleMode;
            _pageSize = pageSize;

            // adjust page size for margins before building grid images
            pageSize.Width -= (margin.Left + margin.Right);
            pageSize.Height -= (margin.Top + margin.Bottom);

            // get grid images for each page
            _pages = flex.GetPageImages(scaleMode, pageSize, maxPages);
        }
 void SetGrid(C1FlexGrid grid)
 {
     if (_grid == null)
     {
         _grid = grid;
         _grid.BeginningEdit += _grid_BeginningEdit;
         _grid.PreviewKeyDown += _grid_PreviewKeyDown;
         _grid.LoadedRows += _grid_LoadedRows;
         _grid_LoadedRows(_grid, EventArgs.Empty);
     }
     else if (grid != _grid)
     {
         throw new Exception("this factory can only be used with a single grid.");
     }
 }
 // finalize custom cell editor
 public override void DisposeCell(C1FlexGrid grid, CellType cellType, FrameworkElement cell)
 {
     var edt = ((Border)cell).Child as FrameworkElement;
     if (edt != null)
     {
         var colorPicker = edt as C1ColorPicker;
         if (colorPicker != null)
         {
             colorPicker.SelectedColorChanged -= StoreCellValue;
         }
         else
         {
             edt.LostFocus -= StoreCellValue;
         }
     }
     base.DisposeCell(grid, cellType, cell);
 }
 public static void ApplyAttributes(C1FlexGrid flex)
 {
     var columnArray = new Column[flex.Columns.Count];
     flex.Columns.CopyTo(columnArray, 0);
     for (int i = 0; i < columnArray.Length; i++)
     {
         Column column = columnArray[i];
         ApplyAttributes(column, "DisplayAttribute");
         ApplyAttributes(column, "DisplayFormatAttribute");
         ApplyAttributes(column, "EditableAttribute");
     }
     for (int i = 0; i < columnArray.Length; i++)
     {
         Column column = columnArray[i];
         ApplyAttributes(column, "DisplayAttribute");
     }
 }
        // bind a cell to a range
        public override void CreateCellContent(C1FlexGrid grid, Border bdr, CellRange range)
        {
            // get row/col
            var row = grid.Rows[range.Row];
            var col = grid.Columns[range.Column];
            var gr = row as GroupRow;

            // no border for group rows
            if (gr != null)
            {
                bdr.BorderThickness = _emptyThickness;
            }

            // bind the tree cells
            if (gr != null && range.Column == 0)
            {
                BindGroupRowCell(grid, bdr, range);
                return;
            }

            // bind cells in regular data rows
            var colName = col.ColumnName;
            if (colName == "Name")
            {
                bdr.Child = new SongCell(row);
                return;
            }
            if (colName == "Rating")
            {
                var song = row.DataItem as Song;
                if (song != null)
                {
                    // create rating control to represent this cell
                    // notes:
                    // - the data context is provided by the Border element, and
                    // - the binding is provided by the column
                    var cell = new RatingCell();
                    cell.SetBinding(RatingCell.RatingProperty, col.Binding);
                    bdr.Child = cell;
                    return;
                }
            }

            // default binding
            base.CreateCellContent(grid, bdr, range);
        }
        public MainWindow()
        {
            InitializeComponent();
            // create the C1FlexGrid
            var flex = new C1FlexGrid();
            LayoutRoot.Children.Add(flex);

            // change appearance a little
            flex.RowBackground = new SolidColorBrush(Color.FromArgb(0xff, 255, 215, 0));
            flex.AlternatingRowBackground = flex.RowBackground;
            flex.GridLinesVisibility = GridLinesVisibility.All;
            flex.Rows.DefaultSize = 60;
            flex.Columns.DefaultSize = 100;
            flex.RowHeaders.Columns.DefaultSize = 80;

            flex.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            flex.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            flex.ColumnHeaders.Rows[0].HeaderHorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            flex.RowHeaders.Columns[0].HeaderHorizontalAlignment = System.Windows.HorizontalAlignment.Right;

            // activate custom merge manager
            flex.AllowMerging = AllowMerging.All;
            flex.MergeManager = new MyMergeManager();

            // add some unbound rows and columns
            for (int cols = 0; cols < 7; cols++)
            {
                flex.Columns.Add(new Column() { HorizontalAlignment = HorizontalAlignment.Center });
            }
            for (int rows = 0; rows < 5; rows++)
            {
                flex.Rows.Add(new Row() { VerticalAlignment = VerticalAlignment.Center });
            }

            // set column headers
            SetData(flex.ColumnHeaders.Rows[0], "Monday\tTuesday\tWednesday\tThursday\tFriday\tSaturday\tSunday");

            // add data
            SetData(flex, 0, "12:00", "Walker\tMorning Show\tMorning Show\tSport\tWeather\tN/A\tN/A");
            SetData(flex, 1, "13:00", "Today Show\tToday Show\tSesame Street\tFootball\tMarket Watch\tN/A\tN/A");
            SetData(flex, 2, "14:00", "Today Show\tToday Show\tKid Zone\tFootball\tSoap Opera\tN/A\tN/A");
            SetData(flex, 3, "15:00", "News\tNews\tNews\tNews\tNews\tN/A\tN/A");
            SetData(flex, 4, "16:00", "News\tNews\tNews\tNews\tNews\tN/A\tN/A");
        }
        // highlight hot cell using two red arrows
        public override void CreateCellContent(C1.WPF.FlexGrid.C1FlexGrid grid, Border bdr, C1.WPF.FlexGrid.CellRange range)
        {
            base.CreateCellContent(grid, bdr, range);
            if (HotRange.Contains(range))
            {
                // save original content
                var child = bdr.Child;
                bdr.Child = null;

                // create grid to hold content and two red arrows
                var g = new Grid();
                g.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(1, GridUnitType.Auto)
                });
                g.ColumnDefinitions.Add(new ColumnDefinition());
                g.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(1, GridUnitType.Auto)
                });

                // set content
                child.SetValue(Grid.ColumnProperty, 1);
                g.Children.Add(child);

                // set left arrow
                var p1 = new Polygon();
                p1.Points            = _leftArrow;
                p1.Fill              = _arrowBrush;
                p1.VerticalAlignment = VerticalAlignment.Center;
                g.Children.Add(p1);

                // set right arrow
                var p2 = new Polygon();
                p2.Points            = _rightArrow;
                p2.Fill              = _arrowBrush;
                p2.VerticalAlignment = VerticalAlignment.Center;
                p2.SetValue(Grid.ColumnProperty, 2);
                g.Children.Add(p2);

                // assign new content to cell
                bdr.Child = g;
            }
        }
        void AddColumnFooter(C1.WPF.FlexGrid.C1FlexGrid flex)
        {
            var gr = new GroupRow();

            // customize appearance of the new row
            gr.CellStyle = new CellStyle()
            {
                BorderThickness     = new Thickness(0),
                FontWeight          = FontWeights.Bold,
                HorizontalAlignment = HorizontalAlignment.Right
            };

            // add the row to the ColumnFooters GridPanel
            flex.ColumnFooters.Rows.Add(gr);

            var aggregatePriceValue    = flexGrid.GetAggregate(Aggregate.Average, new CellRange(0, 5, flexGrid.Rows.Count - 1, 5));
            var aggregateDiscountValue = flexGrid.GetAggregate(Aggregate.Average, new CellRange(0, 8, flexGrid.Rows.Count - 1, 8));

            gr[flexGrid.Columns["Price"]]    = String.Format("Average Price: {0:C2}", aggregatePriceValue);
            gr[flexGrid.Columns["Discount"]] = String.Format("Average Discount : {0:F1}%", aggregateDiscountValue);
        }
        // when cells are destroyed, remove content from borders so it can be re-used
        public override void DisposeCell(C1.WPF.FlexGrid.C1FlexGrid grid, C1.WPF.FlexGrid.CellType cellType, System.Windows.FrameworkElement cell)
        {
            Border bdr = (Border)cell;

            bdr.Child = null;
        }
        private Point GetHit(C1.WPF.FlexGrid.C1FlexGrid grid)
        {
            Point p = new Point(grid.Selection.Column, grid.Selection.Row);

            return(p);
        }