Hi,
is there a way to show a second palette in xamcolorpicker?
or just controling the recent color palette to put in it standard colors? (Like ms excel)
If you are referring to the ability to display two seperate palettes in the color picker at run-time, yes, you can definitely do it. Below is an example of creating a new color picker and defining two custom color palettes in Xaml. If you would like to see this done programmatically, or if I am not correctly understanding you question, just let me know.
Thanks,
Richard P.
<ig:XamColorPicker x:Name="MyColorPicker" Width="200" Height="20"> <ig:XamColorPicker.ColorPalettes> <ig:ColorPaletteCollection> <ig:ColorPalette> <ig:ColorPalette.Colors> <ig:ColorPatch Color="Red"/> <ig:ColorPatch Color="Orange"/> <ig:ColorPatch Color="Yellow"/> <ig:ColorPatch Color="Green"/> <ig:ColorPatch Color="Blue"/> <ig:ColorPatch Color="Indigo"/> <ig:ColorPatch Color="Violet"/> <ig:ColorPatch Color="White"/> </ig:ColorPalette.Colors> </ig:ColorPalette> <ig:ColorPalette> <ig:ColorPalette.Colors> <ig:ColorPatchCollection> <ig:ColorPatch Color="DarkBlue"/> <ig:ColorPatch Color="LightBlue"/> <ig:ColorPatch Color="Orchid"/> <ig:ColorPatch Color="CornflowerBlue"/> <ig:ColorPatch Color="DarkOliveGreen"/> <ig:ColorPatch Color="Lavender"/> <ig:ColorPatch Color="Plum"/> <ig:ColorPatch Color="Crimson"/> <ig:ColorPatch Color="DarkSeaGreen"/> <ig:ColorPatch Color="DeepPink"/> <ig:ColorPatch Color="ForestGreen"/> <ig:ColorPatch Color="SaddleBrown"/> <ig:ColorPatch Color="Honeydew"/> <ig:ColorPatch Color="PaleVioletRed"/> <ig:ColorPatch Color="Thistle"/> </ig:ColorPatchCollection> </ig:ColorPalette.Colors> </ig:ColorPalette> </ig:ColorPaletteCollection> </ig:XamColorPicker.ColorPalettes> </ig:XamColorPicker>
sorry may be i wasnt clear...
the way you suggested, the user will have to choose between palettes through combo.. i want them both visible at the same time..
or if i can control the colors in the recently choosed colors, it will solve my problem
Actually you can change the the style of the Color Picker. Inside the color picker is a combo box that displays the colors. I have taken the generic.xaml for the ColorPicket and modified it so it uses a listbox. This way all of the color palettes availible are visible and clicking on makes it the current palette.
I've attached a zipped MainPage.Xaml that has a modified XamlColorPicker. My sample is written against 10.2 and should work in 10.2 and up. If you are using 10.1 you will need to change the control name to XamWebColorPicker. It you have trouble please let me know and I will help you out. The attached xaml should be enough to get you in the right direction.
I hope that helped, good luck, and let me know if you have any other questions.
Also, regarding the Recent Colors. You do not directly have access to modifying that collection. But you could fake it by rapidly setting the colors you want there. The issue would be every time someone selects a color, your recent color palette would change.
Either way, here is an example on how to do that. Basically we are setting the current color to random colors in our current palette, and this is updating the recent colors palette.
MyTestColorPicker.SelectedColor = MyTestColorPicker.CurrentPalette.Colors[4].Color; MyTestColorPicker.SelectedColor = MyTestColorPicker.CurrentPalette.Colors[3].Color; MyTestColorPicker.SelectedColor = MyTestColorPicker.CurrentPalette.Colors[2].Color;
thanks a lot.. they are both working but i went with your second suggestion
Great, I am glad we were able to help get you to an acceptable solution.
If you need anything else, don't hesitate to ask!
-Richard P.