Trying to override the default current color palette with the following code but it has no effect and the control shows the default. Is this the correct way?
<ig:XamColorPicker HorizontalAlignment="Left" Margin="34,11,0,0" Name="xamColorPicker1" VerticalAlignment="Top" Width="148" SelectedColor="Blue" Grid.Row="1" Grid.Column="1">
<ig:XamColorPicker.CurrentPalette>
<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:XamColorPicker.CurrentPalette>
</ig:XamColorPicker>
Hello,
To override the default, include your palette in the ColorPaletteColection tags:
<ig:ColorPaletteCollection>
</ig:ColorPaletteCollection>
Please let me know if you have any questions.
Valerie
Were you able to resolve your issue?
Not exactly. The support solution was to define a new color palette and then from code behind set the current color pallet to the new one:
xamColorPicker1.CurrentPalette = xamColorPicker1.ColorPalettes[1]; xamColorPicker1.UpdateLayout();
xamColorPicker1.CurrentPalette = xamColorPicker1.ColorPalettes[1];
xamColorPicker1.UpdateLayout();
This appears to be an issue in Silverlight only and the behavior is as expected in WPF. This issue has been logged with development.
I spoke with development on this issue and this is the expected behavior.The correct way to set the current palette in xaml would be as such:
Create a resource dictionary in the xaml that contains a ColorPaletteCollection, and give it a valid x:key for example palettes1.
Then in the xaml for XamColorPicker, you need to do two things.
1.) Set the ColorPalettes to the resource dictionary instance you created.
ex: ColorPalettes={StaticResource palettes1}
2.) Bind the CurrentPalette to a specific instance of the ColorPalettes Resource dictionary above.
ex: CurrentPalette={Binding Source={StaticResource palettes1}, Path=[0]}
You can change the 0 to be whatever index into the ColorPalettes Collection you want.
Here is an example of what the XAML would look like:
<UserControl x:Class="ColorPickerTest.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ig="http://schemas.infragistics.com/xaml"> <Grid x:Name="LayoutRoot" Background="White"> <Grid.Resources> <ig:ColorPaletteCollection x:Key="pal1"> <ig:ColorPalette x:Name="pal1a"> <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> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <StackPanel x:Name="MyTestStack" Orientation="Horizontal" Margin="20" Grid.Row="0" Grid.Column="0"> <ig:XamColorPicker x:Name="MyTestColorPicker" Width="200" Height="20" ColorPalettes="{StaticResource pal1}" CurrentPalette="{Binding Source={StaticResource pal1 }, Path=[1]}"> </ig:XamColorPicker> </StackPanel> </Grid></UserControl>
Let me know if you have any questions.
Do you have any other questions on this matter?