示例#1
0
        private void AddColumn(GridColumn column)
        {
            Logger.Debug("Adding column to column manager: {0}", column.Header);
            switch (column.ColumnType)
            {
            case GridColumn.ColumnTypeEnum.BasicText:
                ColumnManager.AddNewTextColumn(column.Header,
                                               column.Binding, column.IsVisible);
                break;

            case GridColumn.ColumnTypeEnum.Bpm:
                ColumnManager.AddBpmColumn(column.Header,
                                           column.Binding, column.IsVisible);
                break;

            case GridColumn.ColumnTypeEnum.Category:
                var catcol = ColumnManager.AddNewTextColumn(
                    column.Category.CategoryName,
                    "Self",
                    column.IsVisible);
                catcol.Binding = new Binding(Constants.SongBinding)
                {
                    Converter             = SttConverter,
                    ConverterParameter    = column.Category,
                    NotifyOnTargetUpdated = true,
                };

                column.Category.PropertyChanged += (sender, args) =>
                {
                    if (args.PropertyName != "CategoryName")
                    {
                        return;
                    }
                    catcol.Header  = column.Category.CategoryName;
                    catcol.Binding = new Binding(Constants.SongBinding)
                    {
                        Converter             = SttConverter,
                        ConverterParameter    = column.Category,
                        NotifyOnTargetUpdated = true
                    };
                };
                break;

            case GridColumn.ColumnTypeEnum.Tags:
                var col = ColumnManager.AddNewTextColumn(column.Header,
                                                         string.Empty, column.IsVisible);
                col.Binding = new Binding(Constants.SongBinding)
                {
                    Converter             = SttConverter,
                    ConverterParameter    = null,
                    NotifyOnTargetUpdated = true
                };
                break;
            }
        }