The borders around the color visuals (RadColorPaletteViewItem) in the palette view are shown at the wrong visuals when the MainPaletteItemsSource and MainPaletteColumnsCount properties are changed at runtime.
To work this around, re-adjust the PositionState values of the RadColorPaletteViewItems. For example:
private void ChangePalette()
{
this.colorSelector.MainPaletteItemsSource = MyGetSourceMethod();
this.colorSelector.MainPaletteColumnsCount = 10;
UpdatePaletteItems();
}
private void UpdatePaletteItems()
{
var mainPalette = colorSelector.ChildrenOfType<RadColorPaletteView>().First(x => x.Name == "MainPalette");
var paletteItems = mainPalette.ChildrenOfType<RadColorPaletteViewItem>();
var paletteItemsCount = paletteItems.Count();
var columnsCount = mainPalette.PaletteColumnsCount;
var orientation = mainPalette.PaletteOrientation;
for (int i = 0; i < paletteItemsCount; i++)
{
var paletteItem = paletteItems.ElementAt(i);
if ((columnsCount == paletteItemsCount) || (paletteItemsCount / columnsCount == 0))
{
paletteItem.PositionState = PositionState.Single;
return;
}
if (orientation == Orientation.Horizontal)
{
if (i < columnsCount)
{
paletteItem.PositionState = PositionState.Top;
}
else if (i > (paletteItemsCount - columnsCount - 1))
{
paletteItem.PositionState = PositionState.Bottom;
}
else
{
paletteItem.PositionState = PositionState.Middle;
}
}
else
{
if (i % (paletteItemsCount / columnsCount) == 0)
{
paletteItem.PositionState = PositionState.Top;
}
else if (((i + 1) % (paletteItemsCount / columnsCount)) == 0)
{
paletteItem.PositionState = PositionState.Bottom;
}
else
{
paletteItem.PositionState = PositionState.Middle;
}
}
}
}