-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataGrid edit text wrong color theme - Version 2023 #28
Comments
I'll try and fix this. The microsoft docs about data grid styles are pretty lacking |
I looked at the source code and it seems like it's not possible to set the implicit styles... The |
I added a new update with the |
|
I was messing around with the In the old version works as well and the private void DataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
{
var dataGrid = sender as DataGrid;
if (e.Column is DataGridTextColumn dataGridTextColumn)
{
if (new DataGridTextColumn().ElementStyle == dataGridTextColumn.ElementStyle)
{
dataGridTextColumn.ElementStyle = null;
}
if (new DataGridTextColumn().EditingElementStyle == dataGridTextColumn.EditingElementStyle)
{
dataGridTextColumn.EditingElementStyle = null;
}
}
if (e.Column is DataGridComboBoxColumn dataGridComboBoxColumn)
{
if (new DataGridComboBoxColumn().EditingElementStyle == dataGridComboBoxColumn.EditingElementStyle)
{
dataGridComboBoxColumn.EditingElementStyle = null;
}
}
if (e.Column is DataGridCheckBoxColumn dataGridCheckBoxColumn)
{
if (new DataGridCheckBoxColumn().ElementStyle == dataGridCheckBoxColumn.ElementStyle)
{
dataGridCheckBoxColumn.ElementStyle = null;
}
if (new DataGridCheckBoxColumn().EditingElementStyle == dataGridCheckBoxColumn.EditingElementStyle)
{
dataGridCheckBoxColumn.EditingElementStyle = null;
}
}
} This is the code I'm using to compare if the datagrid column has a default style if is the case set to null. 😅 |
Looks like we're seeing the same issue, unrelated to the DataGrid, but related to the ContentPresenter that's a part of the Extended WPF Toolkit's CheckComboBox. So a widespread issue with implicit styles applied to ComboBox-like elements overwriting (?) pre-defined styles. Not sure if this adds anything at all to the discussion. I'm definitely lost when it comes to putting together a potential solution (even a work-around 😅) |
It could be because you don't have a style for the If you do though... well I haven't used the toolkit myself, but at a guess based on what WPF does sometimes, maybe there's some resource keys that they have defined that allows you to override the default styles?
So if you can find them, you might be able to just use the above xaml to 'delegate' the styles |
Same problem here. I fixed it this way: private void grdAccurateWorkTime_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
{
if (isAnyRowEditing())
{
e.Cancel = true;
}
//...
if (e.Column is DataGridComboBoxColumn)
{
DataGridComboBoxColumn cbCol = (DataGridComboBoxColumn)e.Column;
Style comboboxStyle = new Style(typeof(ComboBox), (Style)TryFindResource("DataGridComboBoxColumnEditingElementStyle"));
if (comboboxStyle != null)
{
cbCol.EditingElementStyle = comboboxStyle;
}
}
} But would be easier, if it works out of the box. |
Hello @AngryCarrot789
First of all great update! I was trying to update the DataGrid but I having a hard time, wpf style is not my best skill.
I found that the DataGrid when editing the text is not changing to the proper theme color.
I don't know how to fixed that yet. 😑
The text was updated successfully, but these errors were encountered: