Hello,
I have a dataTable bind to a XamDataGrid. One of the columns in the dataTable is string which represents color. I want that when the dataGrid is loaded this color column will be shown as colorPicker in the cells with the right color selected. And i could change the color using this colorPicker. How can i do it? I saw an example how to add a color to a dataGrid cell but i don't know how to show the selected Color from the dataTable when the dataGrid is loaded using binding.
Can you send a sample how can i do it? thanks.
Hello Michael,
Excuse me for the late reply. I have been looking into your requirement and have been working on a sample (Grid_ColorPicker.zip), where the implementation would interfere with the XamDataGrid’s functionality to the minimum. Also I wasn’t sure in what format were your string colors so I created a converter which work for both the Colors static class’ values and also with the hexadecimal string representation of the ARGB colors.
Please check it out and let me know if I can further assist you on the matter or if you require any clarification regarding my implementation.
Thanks very much.
Now i have another question. I have another dataGrid which has the Name column (and many other columns). I want that the color that is picken in the colors table which you wrote a sample to will represent the background of the right row in the other dataGrid.
For example. if i set :
michael- green
Jack- blue
that in the other dataGrid, whenever the value in the name cell is michael than the entire row will be green and whenever jack than blue. If nothing is set than it will be white.
How can i do it?
Hi again,
I have been looking into your description and here is what I came up with. I have modified the sample I had created before and reattached it.
Please let me know if you require any further clarification on the matter.
Hi,
I actually did it another way:
<igDP:XamDataGrid.Resources>
<Style TargetType="{x:Type igDP:DataRecordCellArea}">
<Setter Property="Background" Value="{Binding Path=DataItem.Product, Converter={StaticResource colorConvert}}" />
</Style>
</igDP:XamDataGrid.Resources>
and inside the converter i just did:
foreach (DataRow Row in App.dtDashboardProject.Rows)
{
//string project = Row["Project"].ToString();
if (Row["Project"].ToString() == value.ToString())
//string color = Row["Color"].ToString();
return Row["Color"].ToString();
}
return "White";
The App.dtDashboardProject is a dataTable which contains the project-->color settings. This table is taken from DB.
I am glad to hear that you have worked this out. If you don’t have any further questions on the matter please verify this thread as answered so it helps other user as well.