I'm creating a control in my application that autogenerates columns for my datagrid regardless of the object passed to ItemsSource.
However, I am failing to understand how the DataTemplate class operates.
Below is my code...
[code]
else if (type == typeof(Color))
{
DataTemplate colorTemplate = new DataTemplate();
colorTemplate.DataType = typeof(string);
// WHAT DO I DO HERE TO ADD A COLORPICKER TO THE TEMPLATE
GridDataColumnStyle style = new GridDataColumnStyle();
style.CellItemTemplate = colorTemplate;
col.ColumnStyle = style;
}
[/code]
I can accomplish this in WPF but not in C#
[code]
<Grid.Resources>
<DataTemplate x:Key="ColorTemplate">
<syncfusion:ColorPicker Color="{Binding CellBoundValue, Mode=TwoWay}" />
</DataTemplate>
</Grid.Resources>
<syncfusion:GridDataControl x:Name="GridMain"
Grid.Row="2"
VisualStyle="{Binding GridVisualStyle}"
ItemsSource="{Binding CurrentRecords}" Margin="0,0,10,0">
<syncfusion:GridDataControl.VisibleColumns>
<syncfusion:GridDataVisibleColumn HeaderText="Color" MappingName="Color" CellItemTemplate="{StaticResource ColorTemplate}" CellEditItemTemplate="{StaticResource ColorTemplate}"/>
</syncfusion:GridDataControl.VisibleColumns>
</syncfusion:GridDataControl>
[/code]
Thank you!