Frappeer
Frappeer

Reputation: 29

Implement Custom Color Picker for Windows Phone

I try to implement this Color Picker. But I have problem with "ColorToBrushConverter". Where and how can I add him to the project ?

Error list:

Error 1 Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'CustomColorsPicker.Converters' that could not be found.

Error 2 The resource "ColorToBrushConverter" could not be resolved.

Upvotes: 1

Views: 345

Answers (1)

bendewey
bendewey

Reputation: 40235

I don't see one on the site, but you can easily write one yourself.

namespace MyApp.Converters
{
    using System;
    using System.Windows.Data;
    using System.Windows.Media;

    public class ColorToBrushConverter : IValueConverter
    {
       private readonly SolidColorBrush MagentaBrush = new SolidColorBrush(Colors.Magenta);

       public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var color = value as Color;
            if (color != null)
            {
                return new SolidColorBrush(color);
            }
            return MagentaBrush ;
        }

        public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return null;
        }
    }
}

Upvotes: 1

Related Questions