Hello,
I tried doing something like:
<ig:XamColorPicker.ColorPalettes>
<!-- Create Custom Palette -->
<!--<ig:ColorPalette>
<ig:ColorPalette.Colors>
<ig:ColorPatchCollection>
<ig:ColorPatch Color="242, 108, 79"/>
</ig:ColorPatchCollection>
</ig:ColorPalette.Colors>
</ig:ColorPalette>-->
<!--</ig:XamColorPicker.ColorPalettes>
It want build. I tried also using <ig:ColorPatch Color="255, 242, 108, 79"/> with same results.
I do have a custom palette, carefully chosen from the Photoshop Swatches that looks like the following:
public static IEnumerable<Color> OwnerColors { get { List<Color> ownerColors = new List<Color>(); ownerColors.Add(Color.FromArgb(242, 108, 79)); ownerColors.Add(Color.FromArgb(246, 142, 86)); ownerColors.Add(Color.FromArgb(251, 175, 93)); ownerColors.Add(Color.FromArgb(255, 244, 104)); ownerColors.Add(Color.FromArgb(172, 211, 115)); ownerColors.Add(Color.FromArgb(124, 197, 118)); ownerColors.Add(Color.FromArgb(60, 184, 120)); ownerColors.Add(Color.FromArgb(28, 187, 180)); ownerColors.Add(Color.FromArgb(0, 191, 243)); ownerColors.Add(Color.FromArgb(68, 104, 202)); ownerColors.Add(Color.FromArgb(85, 116, 185)); ownerColors.Add(Color.FromArgb(96, 92, 168)); ownerColors.Add(Color.FromArgb(133, 96, 168)); ownerColors.Add(Color.FromArgb(168, 99, 168)); ownerColors.Add(Color.FromArgb(240, 110, 169)); ownerColors.Add(Color.FromArgb(242, 109, 125)); return ownerColors; } }
Is there a way I could bind it to the colors of the xamColorPicker? Possiblu something that worksboth in Silverlight and WPF.
Thanks
Roberto
Hi Roberto,
I got the following information from the MSDN site concerning Colors class
http://msdn.microsoft.com/en-us/library/system.windows.media.colors.aspx
//Describes the brush's color using
// RGB values. Each value has a range of 0-255.
// R is for red, G is for green, and B is for blue.
// A is for alpha which controls transparency of the
//color. Therefore, to make a completely transparent
// color (invisible), use a value of 0 for Alpha.
I added a control to my window
<ig:XamColorPicker x:Name="custColorPicker" Width="100" Height="35"/>
And I was able to create a colorPalette for the xamColorPicker with the following code.
ColorPalette cp = new ColorPalette();
cp.Colors.Add(Color.FromArgb(255,242,108,79));
cp.Colors.Add(Color.FromArgb(255,242, 108, 79));
cp.Colors.Add(Color.FromArgb(255,246, 142, 86));
cp.Colors.Add(Color.FromArgb(255,251, 175, 93));
cp.Colors.Add(Color.FromArgb(255,255, 244, 104));
cp.Colors.Add(Color.FromArgb(255,172, 211, 115));
cp.Colors.Add(Color.FromArgb(255,124, 197, 118));
cp.Colors.Add(Color.FromArgb(255,60, 184, 120));
cp.Colors.Add(Color.FromArgb(255,28, 187, 180));
cp.Colors.Add(Color.FromArgb(255,0, 191, 243));
cp.Colors.Add(Color.FromArgb(255,68, 104, 202));
cp.Colors.Add(Color.FromArgb(255,85, 116, 185));
cp.Colors.Add(Color.FromArgb(255,96, 92, 168));
cp.Colors.Add(Color.FromArgb(255,133, 96, 168));
cp.Colors.Add(Color.FromArgb(255,168, 99, 168));
cp.Colors.Add(Color.FromArgb(255,240, 110, 169));
cp.Colors.Add(Color.FromArgb(255,242, 109, 125));
custColorPicker.ColorPalettes.Add(cp);
Please let me know if you have any questions.
Hello Marianne,my code is already working (I know I need 4 arguments, the first one being transparency). Since I'm porting my application from Winforms to Silverlight/WPF I used in the sample what I was using before.
Let me be more clear:1) It would be nice to be able to specify the colors in xaml with those 4 parameters2) Is there a way to bind those colors from the ViewModel?
Thank youRoberto
You can specify each colorpatch color in xaml like this.
<ig:ColorPatch>
<ig:ColorPatch.Color>
<Color A="255" R="255" G="0" B="0" />
</ig:ColorPatch.Color>
</ig:ColorPatch>
Let me know if that is what you had in mind.
Hey Marianne,
that was exactly what I was looking for.
Thank you
Hi,
Glad I could help. Let me know if you have any further questions.