Click here to Skip to main content
15,888,325 members
Home / Discussions / WPF
   

WPF

 
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 
GeneralRe: Need assistance on WPF Pin
Hema Bairavan4-Nov-12 18:21
Hema Bairavan4-Nov-12 18:21 
GeneralHow to Print & Export Search Results in WPF using MVVM? Pin
Satheeskumar Manickam25-Oct-12 7:18
Satheeskumar Manickam25-Oct-12 7:18 
AnswerRe: How to Print & Export Search Results in WPF using MVVM? Pin
Richard MacCutchan25-Oct-12 22:26
mveRichard MacCutchan25-Oct-12 22:26 
AnswerRe: How to Print & Export Search Results in WPF using MVVM? Pin
Mycroft Holmes26-Oct-12 0:58
professionalMycroft Holmes26-Oct-12 0:58 
QuestionFrom WinForms to WPF and XAML problem with properties (not Dependency)... Pin
User 224816825-Oct-12 1:59
User 224816825-Oct-12 1:59 
AnswerRe: From WinForms to WPF and XAML problem with properties (not Dependency)... Pin
Pete O'Hanlon25-Oct-12 2:11
mvePete O'Hanlon25-Oct-12 2:11 
GeneralRe: From WinForms to WPF and XAML problem with properties (not Dependency)... Pin
User 224816825-Oct-12 2:51
User 224816825-Oct-12 2:51 
GeneralRe: From WinForms to WPF and XAML problem with properties (not Dependency)... Pin
Pete O'Hanlon25-Oct-12 3:01
mvePete O'Hanlon25-Oct-12 3:01 
GeneralRe: From WinForms to WPF and XAML problem with properties (not Dependency)... Pin
User 224816825-Oct-12 3:14
User 224816825-Oct-12 3:14 
GeneralRe: From WinForms to WPF and XAML problem with properties (not Dependency)... Pin
Pete O'Hanlon25-Oct-12 3:32
mvePete O'Hanlon25-Oct-12 3:32 
GeneralRe: From WinForms to WPF and XAML problem with properties (not Dependency)... Pin
User 224816825-Oct-12 3:58
User 224816825-Oct-12 3:58 
GeneralRe: From WinForms to WPF and XAML problem with properties (not Dependency)... Pin
Pete O'Hanlon25-Oct-12 4:33
mvePete O'Hanlon25-Oct-12 4:33 
GeneralRe: From WinForms to WPF and XAML problem with properties (not Dependency)... Pin
User 224816825-Oct-12 22:03
User 224816825-Oct-12 22:03 
GeneralRe: From WinForms to WPF and XAML problem with properties (not Dependency)... Pin
Pete O'Hanlon25-Oct-12 22:09
mvePete O'Hanlon25-Oct-12 22:09 
GeneralRe: From WinForms to WPF and XAML problem with properties (not Dependency)... Pin
User 224816825-Oct-12 22:35
User 224816825-Oct-12 22:35 

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.