Ejemplo n.º 1
0
 public BTreeView(ExcelDataItem data)
 {
     this.data       = data;
     this.Header     = data.header;
     this.FontSize   = 15;
     this.IsExpanded = false;
     this.Visibility = Visibility.Visible;
     //this.ItemsSource = itemList;
 }
Ejemplo n.º 2
0
        public static UCTabItemWithClose NewItem(ExcelDataItem content, TAB_ITEM itemType = TAB_ITEM.CONTENT)
        {
            UCTabItemWithClose item = new UCTabItemWithClose(itemType);

            item.data = content;
            if (content != null)
            {
                item.Header  = content.header;
                item.ToolTip = content.header;
            }
            item.FontSize = MainConfig.Instance.tableFontSize;
            DataGrid data = new DataGrid();

            //让DataUnit不会自动生成列
            data.AutoGenerateColumns = false;
            //不能主动添加行
            data.CanUserAddRows = false;
            //不能排序
            data.CanUserSortColumns = false;
            //单元格选中
            data.SelectionUnit = DataGridSelectionUnit.Cell;
            //单元格单选
            data.SelectionMode = DataGridSelectionMode.Single;
            //单元格选中后更新右键菜单
            data.SelectedCellsChanged += (object sender, SelectedCellsChangedEventArgs e) =>
            {
                OnRightClick(data, sender, e);
            };
            data.ContextMenu = new ContextMenu();
            foreach (var it in TabItemControl.NewGridConfig())
            {
                data.Columns.Add(it);
            }
            data.MaxWidth = TabItemControl.TABLE_MAX_WIDTH;
            if (content != null)
            {
                data.ItemsSource = new ObservableCollection <DataUnit>(item.DataList);
            }
            Grid grid = new Grid();

            grid.Children.Add(data);
            item.Content = grid;

            if (itemType != TAB_ITEM.CONTENT)
            {
                item.Width = MainConfig.Instance.tableArrowItemWidth;
            }
            else
            {
                item.Width = MainConfig.Instance.tableItemWidth;
            }
            return(item);
        }