Am autogenerating columns in a datagrid
The DataGridCOmboboxColumn generated is not styled.
How do I fix this?
Am autogenerating columns in a datagrid
The DataGridCOmboboxColumn generated is not styled.
How do I fix this?
If you use Reflector and look at the source of DataGridComboBoxColumn.GenerateEditingElement, they apply a Style to the ComboBox. Therefore our themed implicit Style that targets ComboBox (assuming your have our native themes on) won't be able to apply to it. You'd probably need to override that method and clear out the Style value.
Great Response.
Derived a class from ThemedGrid.
Overroad this method.
YOu might want to consider this in your implementation
protected override void OnAutoGeneratingColumn(DataGridAutoGeneratingColumnEventArgs e)
{
if (e.Column is DataGridComboBoxColumn)
{
((DataGridComboBoxColumn) e.Column).EditingElementStyle = null;
((DataGridComboBoxColumn)e.Column).ElementStyle = null;
}
base.OnAutoGeneratingColumn(e);
}
Hi Jack,
We've updated the next maintenance release to apply our themed styles for ComboBox and CheckBox columns that are auto-generated per that method override you mentioned. However please note that it will only work for auto-generated columns. If you explicitly define your columns, you'd still have to manually apply a style.
That being said, there is an easier way to do the style when not using auto-generated columns. You'd set these two properties like this:
<DataGridComboBoxColumn MinWidth="100"
ElementStyle="{StaticResource {x:Static themes:SharedResourceKeys.ComboBoxStyleKey}}"
EditingElementStyle="{StaticResource {x:Static themes:SharedResourceKeys.ComboBoxStyleKey}}" />
Please log in to a validated account to post comments.