How to change listbox item's color individually programmatically in silverlight?

Have a look at the following link forums.create.msdn.com/forums/p/74900/45... It has working solution of changing the foreground color of selected item. So when you get the message, you mark it as selected item with the style, you can change the foreground color of the text.

Have a look at the following link; forums.create.msdn.com/forums/p/74900/45... It has working solution of changing the foreground color of selected item. So when you get the message, you mark it as selected item with the style, you can change the foreground color of the text.

Ok do this.. Create a class public class MSGS { public string color {get;set;} public string message {get;set;} } now instead of adding items in List create List and set message equal to message and if message is sent then set color to let's say Blue or if message is received set color to Red. MSGS one = new MSGS (); one. Message = "testing"; one.

Color = "Red"; MSGS two = new MSGS(); two. Message = "testing2"; two. Color = "Blue"; MSGS three = new MSGS(); three.

Message = "testing3"; three. Color = "Red"; List list = new List (); list. Add(one); list.

Add(two); list. Add(three); myLB. ItemsSource = list; define a style for listboxitem like this in XAML this code will show the received messages and sent messages in different colors More Detailed Approach try style below instead of of style above Have taken this from http://forums.silverlight.net/forums/p/35969/113333.aspx If you want to know more about styling check these links http://weblogs.asp.net/scottgu/pages/silverlight-tutorial-part-4-using-style-elements-to-better-encapsulate-look-and-feel.aspx http://www.silverlightshow.net/items/Skinning-and-Styling-Silverlight-Controls.aspx.

Thank you very very much for this. But ı could not clearly understand how styling works here. Can you help me understand this clearly please.Do you know any resource for learning it – kolgibi Jun 16 at 14:38 there is a problem.

I cannot select items,some of the functionalities are disappeard. Can you help me about it? – kolgibi Jun 16 at 14:41 use the updated code.

I know its complex but that's the right way to solve this issue. You can go through links I specified to know more about styling also try googling it you will find a lot of useful stuff – Haris Hasan Jun 16 at 15:31.

You can change the text foreground of the item. Item. Foreground = new SolidColorBrush(Colors.

Green).

As indicated from question, I am using listbox. – kolgibi Jun 16 at 13:51 regardless, you can still use the foreground property - answer updated to reflect this – JD. Jun 17 at 1:42.

I made an example with binding that makes use of a Style Converter. You can read the whole implementation and sample here: vanderbiest.org/blog/2011/07/12/listbox-... Listbox Implementation Converter Implementation public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if ((bool)value) { return Application.Current. Resources"ListBoxTextNormalItem"; } return Application.Current.

Resources"ListBoxTextErrorItem"; } Style Implementation.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions