/// <summary>
        /// Creates a color preview control with data binding.
        /// </summary>
        /// <param name="d">The cell definition.</param>
        /// <returns>
        /// A preview control.
        /// </returns>
        protected virtual FrameworkElement CreateColorPreviewControl(ColorCellDefinition d)
        {
            var c = new Rectangle
            {
                Stroke              = Brushes.Black,
                StrokeThickness     = 1,
                Width               = 12,
                Height              = 12,
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            // Bind to the data context, since the binding may contain a custom converter
            var contextBinding = this.CreateBinding(d);

            c.SetBinding(FrameworkElement.DataContextProperty, contextBinding);

            this.SetIsEnabledBinding(d, c);

            // Convert the color in the data context to a brush
            var fillBinding = new Binding {
                Converter = new ColorToBrushConverter()
            };

            c.SetBinding(Shape.FillProperty, fillBinding);

            // Create a grid for the data context
            var grid = new Grid();

            grid.Children.Add(c);

            // Create a container to support background binding
            return(this.CreateContainer(d, grid));
        }
        /// <summary>
        /// Creates a color preview control with data binding.
        /// </summary>
        /// <param name="d">The cell definition.</param>
        /// <returns>
        /// A preview control.
        /// </returns>
        protected virtual FrameworkElement CreateColorPreviewControl(ColorCellDefinition d)
        {
            var c = new Rectangle
            {
                Stroke = Brushes.Black,
                StrokeThickness = 1,
                Width = 12,
                Height = 12,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            var binding = this.CreateBinding(d);
            binding.Converter = new ColorToBrushConverter();
            c.SetBinding(Shape.FillProperty, binding);
            this.SetIsEnabledBinding(d, c);

            var grid = new Grid();
            grid.Children.Add(c);
            this.SetBackgroundBinding(d, grid);
            this.SetIsEnabledBinding(d, grid);
            return grid;
        }