WordPress database error: [INSERT, UPDATE command denied to user '51213-2'@'10.10.20.194' for table 'wp_options']INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1714969442.4976680278778076171875', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
<\/a>Today I found out a strange behavior in the DataGridCheckBoxColumn: it was not using the default template I set in the resources for the CheckBoxes and uses the default WPF’s one instead. This happens always when you set the AutoGeneratedColumns option to true and a work-around exists otherwise.<\/p>\n <\/p>\n My fellow geek Jacob Reimers<\/a> found out that it was a bug in the DataGridCheckBoxColumn’s implementation. Instead of seeking for a Style in the resources, the DataGridCheckBoxColumn creates a new one from scratch and assign it to the CheckBox if you don’t set the ElementStyle property. When the columns are auto-generated, the ElementStyle can’t be set and you have no choice than to have this default style. When you don’t auto-generate the columns, you can set your own custom style and override the default one (happy us !).<\/p>\n Jacob told me: “why don’t you register to the DataGrid’s AutoGeneratingColumn event and set the ElementStyle there ?<\/em><\/strong>“. That’s actually a great idea and it works like a charm. Here is the snippet which performs it:<\/p>\n [csharp] As I was porting the Jetpack Theme to WPF<\/a>\u00a0I thought it was a little embarrasing to force the users to handle an event just to fix this – little – bug. <\/p>\n So I came up with this enhanced solution in two parts:<\/p>\n <\/strong><\/p>\n As you are now experts with attached properties<\/a>, I let you discover the code directly on Codeplex<\/a>. <\/p>\n On the other hand, here is the default Style setter I use for the DataGrid:A work-around exists(ourah !)<\/h4>\n
\nvoid grid_AutoGeneratingColumn(object sender,
\n DataGridAutoGeneratingColumnEventArgs e)
\n{
\n if(e.Column is DataGridCheckBoxColumn)
\n {
\n var checkBoxColumn = e.Column as DataGridCheckBoxColumn;
\n var resource = Application.Current.FindResource(typeof(CheckBox));
\n checkBoxColumn.ElementStyle = resource as Style;
\n }
\n}
\n[\/csharp]<\/p>\n\n
\n[xml]<Style TargetType="{x:Type DataGrid}">
\n <Setter Property="helpers:DataGridCheckBoxColumnFixer.Fix" Value="True" \/>
\n<\/Style>[\/xml]<\/p>\n