Пример #1
0
 public ColHeaderCell(Col p_col, ColHeader p_owner)
 {
     DefaultStyleKey = typeof(ColHeaderCell);
     Col             = p_col;
     _owner          = p_owner;
     Title           = p_col.Title;
     Loaded         += OnLoaded;
 }
Пример #2
0
        void CreateColHeader()
        {
            // 只附加一次
            _owner.Cols.Update += (s, e) => InvalidateMeasure();
            _colHeader          = new ColHeader(_owner);

            // 左上角
            _topLeftWidth = (_owner.SelectionMode == SelectionMode.Multiple) ? 81 : 40;
            if (_owner.SelectionMode == SelectionMode.Multiple)
            {
                Grid grid = new Grid
                {
                    Background        = Res.浅灰背景,
                    BorderBrush       = Res.浅灰边框,
                    BorderThickness   = new Thickness(0, 0, 1, 1),
                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = new GridLength(0f, GridUnitType.Auto)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(0f, GridUnitType.Auto)
                        },
                    },
                };

                Button btn = new Button
                {
                    Style   = Res.字符按钮,
                    Content = "\uE020",
                };
                ToolTipService.SetToolTip(btn, "全选");
                btn.Click += (s, e) => _owner.SelectAll();
                grid.Children.Add(btn);

                btn = new Button
                {
                    Style   = Res.字符按钮,
                    Content = "\uE009",
                };
                ToolTipService.SetToolTip(btn, "清除所选");
                btn.Click += (s, e) => _owner.ClearSelection();
                Grid.SetColumn(btn, 1);
                grid.Children.Add(btn);
                _topLeft = grid;
            }
            else
            {
                _topLeft = new Border
                {
                    Background       = Res.浅灰背景,
                    BorderBrush      = Res.浅灰边框,
                    BorderThickness  = new Thickness(0, 0, 1, 1),
                    IsHitTestVisible = false,
                };
            }
        }
Пример #3
0
 protected override void ClearColHeader()
 {
     _colHeader = null;
     _topLeft   = null;
 }