There is a vb control which takes a long value of 235 as its backcolor and thus gives out a color similar to red color. However in wpf we do not have any equivalent function that takes long value for color, therefore i have written following code:
System.Drawing.Color colorLong = System.Drawing.Color.FromArgb(235); Brush color = new SolidColorBrush(Color.FromRgb( colorLong.R, colorLong.G, colorLong.B)); ctrl.Brush = color;
The above code works for large values but for value say 235 in vb it is giving a color similar to red one but in wpf it is giving blue color .
What is going wrong here? What to do in this case?
You are correct, System.Drawing.Color.FromArgb(235) will definitely give you a blue color. Why? You are specifying a 32bit value of the AARRGGBB format. 235 translates to 000000EB in hex. See http://msdn.microsoft.com/en-us/library/2zys7833.aspx. Red would be 00FF0000 in hex (16711680 in decimal).
If you are just trying to get a red color you can use Colors.Red.
Last edited by gurge60; March 25th, 2009 at 06:16 PM.