Completed
Last Updated: 20 Sep 2023 07:01 by ADMIN
Release R3 2023
Martin Ivanov
Created on: 18 Aug 2023 13:41
Category: ColorPicker
Type: Bug Report
1
ColorSelector: The border of the color visuals in the palette is displayed at the wrong position when changing the MainPaletteItemsSource and MainPaletteColumnsCount at runtime

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;
			}
		}
	}
}

0 comments