Click here to Skip to main content
15,911,785 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: slide menu Pin
Richard MacCutchan2-Nov-12 10:27
mveRichard MacCutchan2-Nov-12 10:27 
QuestionCustomized Scrollbar not working properly Pin
Anil_S.Kamble2-Nov-12 5:11
Anil_S.Kamble2-Nov-12 5:11 
QuestionCustom TreeViewItems Pin
#realJSOP2-Nov-12 4:06
professional#realJSOP2-Nov-12 4:06 
AnswerRe: Custom TreeViewItems Pin
SledgeHammer012-Nov-12 6:47
SledgeHammer012-Nov-12 6:47 
QuestionHow to detect if the users pressed Ctrl and V at the same time? Pin
gmf1-Nov-12 11:26
gmf1-Nov-12 11:26 
AnswerRe: How to detect if the users pressed Ctrl and V at the same time? Pin
Pete O'Hanlon1-Nov-12 11:49
mvePete O'Hanlon1-Nov-12 11:49 
GeneralRe: How to detect if the users pressed Ctrl and V at the same time? Pin
gmf1-Nov-12 13:28
gmf1-Nov-12 13:28 
GeneralRe: How to detect if the users pressed Ctrl and V at the same time? Pin
Pete O'Hanlon1-Nov-12 13:34
mvePete O'Hanlon1-Nov-12 13:34 
QuestionXAML Diff Source Compare Pin
_Maxxx_30-Oct-12 15:04
professional_Maxxx_30-Oct-12 15:04 
AnswerRe: XAML Diff Source Compare Pin
Mycroft Holmes30-Oct-12 17:42
professionalMycroft Holmes30-Oct-12 17:42 
GeneralRe: XAML Diff Source Compare Pin
_Maxxx_30-Oct-12 23:19
professional_Maxxx_30-Oct-12 23:19 
AnswerRe: XAML Diff Source Compare Pin
Abhinav S30-Oct-12 21:22
Abhinav S30-Oct-12 21:22 
GeneralRe: XAML Diff Source Compare Pin
_Maxxx_30-Oct-12 23:20
professional_Maxxx_30-Oct-12 23:20 
AnswerRe: XAML Diff Source Compare Pin
Pete O'Hanlon30-Oct-12 22:32
mvePete O'Hanlon30-Oct-12 22:32 
GeneralRe: XAML Diff Source Compare Pin
_Maxxx_30-Oct-12 23:24
professional_Maxxx_30-Oct-12 23:24 
QuestionHow to set the wcf ria service time out. Pin
Saurabh_0829-Oct-12 11:32
Saurabh_0829-Oct-12 11:32 
AnswerRe: How to set the wcf ria service time out. Pin
Keith Barrow29-Oct-12 23:18
professionalKeith Barrow29-Oct-12 23:18 
QuestionDownload Xap file in silverlight4.0 Pin
Saurabh_0829-Oct-12 11:28
Saurabh_0829-Oct-12 11:28 
AnswerRe: Download Xap file in silverlight4.0 Pin
Mycroft Holmes29-Oct-12 12:56
professionalMycroft Holmes29-Oct-12 12:56 
AnswerRe: Download Xap file in silverlight4.0 Pin
Abhinav S30-Oct-12 6:40
Abhinav S30-Oct-12 6:40 
QuestionBinding from a lookup Pin
cjb11029-Oct-12 5:18
cjb11029-Oct-12 5:18 
AnswerRe: Binding from a lookup Pin
Keith Barrow29-Oct-12 6:25
professionalKeith Barrow29-Oct-12 6:25 
GeneralRe: Binding from a lookup Pin
cjb11031-Oct-12 1:10
cjb11031-Oct-12 1:10 
Ah that makes sense!

In my case I wanted to provide a visual indication that text items where different.
I didn't care about the colour used though, so I originally created a random colour in a collection in the VM and it was that collection I was trying to lookup.

But I realised that as long as the colour was the same for the same string, then the conversion from string to colour had nothing to do with my model or viewmodel.

So I created an IValueConvertor:
C#
public class StringToColorConvertor : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (!(value is string))
                throw new ArgumentException("value is not a string");

            string text = (string) value;
            byte[] data;

            //create a 16 byte md5 hash of the string
            using (MD5 md5 = MD5.Create())
                data = md5.ComputeHash(Encoding.UTF8.GetBytes(text));

            //use 3 values from the hash to create the color
            //provide an alpha value to prevent readability issues if this color is used as a text background
            return new SolidColorBrush(Color.FromArgb(150, data[0], data[7], data[15]));
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

If your using similar ish strings you might get colours close together, but for my set of 5 pairs, each colour was different enough to be recognizable.
QuestionNeed assistance on WPF Pin
Hema Bairavan27-Oct-12 6:56
Hema Bairavan27-Oct-12 6:56 
AnswerRe: Need assistance on WPF Pin
Abhinav S30-Oct-12 6:40
Abhinav S30-Oct-12 6:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.