Implicit style support for bound columns

Feb 20, 2009 at 1:46 PM
Do DataGridBoundColumns such as DataGridCheckBoxColumn support implicit styling? I try to make all the check boxes in my app look same (including the check boxes in DataGridCheckBox columns). Normal implicit styling like below doesn't seem to work (this is defined in ResourceDictionary):

<Style TargetType="{x:Type CheckBox}">

Neither does this approach (this is also defined in ResourceDictionary):

<Style TargetType="{x:Type Toolkit:DataGridCheckBoxColumn}">
  <Setter Property="ElementStyle">
      <Style TargetType="{x:Type CheckBox}">

However, if I define style explicitly it seems to work, but this is something I wouldn't like to do (this is defined in directly inside DataGrid definition):

<Toolkit:DataGridCheckBoxColumn Header="..."
    <Style TargetType="{x:Type CheckBox}">

So, is there a mechanism for implicitly defining style for DataGridBoundColumns (maybe something like the style keys with Toolbar) or do I have to define all styles explicitly?
Feb 23, 2009 at 6:46 AM
Does anybody know answer to this?
Feb 23, 2009 at 6:32 PM
Hi annyman,

DataGridColumn derives from DependencyObject, and therefore does not have a Style property.  For an explanation of why this is, see this thread:

Instead, you'll want to apply a Style to the visual element in the cell.  In the case above, you'd want to apply it to CheckBox.  Alternatively, you can use the explicit ElementStyle like you did above also.