private static void OnGlyphsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            EditorGrid grid = d as EditorGrid;

            grid.items.Clear();

            if (e.OldValue != null)
            {
                ((ObservableCollection <Glyph>)e.OldValue).CollectionChanged -= grid.glyphsChanged;
            }
            if (e.NewValue != null)
            {
                ((ObservableCollection <Glyph>)e.NewValue).CollectionChanged += grid.glyphsChanged;
            }

            int col = 0;
            int row = 0;

            foreach (var item in ((ObservableCollection <Glyph>)e.NewValue))
            {
                grid.items.Add(new EditorGlyph(item, row, col));

                col++;

                if (col >= grid.ColumnCount)
                {
                    col = 0;
                    row++;
                }
            }
        }
        private static void OnColumnCountChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            EditorGrid grid = d as EditorGrid;

            grid.CorrectColumnCount();
        }