Question

I am working with a Wpf application. I have created a custom style for wpf DataGrid (provided in Wpf Toolkit). It all works fine except that I am unable to apply a Style on the TextBox that comes on double clicking the cell(editable mode) in DataGridTextColumn. It display as default style and that doesn't match with my style and looks odd. I have applied a style on the ComboBox in DataGridComboBoxColumn and the CheckBox and all other controls, but this one is not working. Any help plz!!!

Edit:

I have a control library and every control is overridden here for customization (additional functionality) and restyling. These controls are used through out the application. I have to apply this style on the control in control library. So that I can get it reflected in my whole application.

Was it helpful?

Solution

Not perfect, but works...

<Style x:Key="DataGridTextBoxStyle"
    TargetType="TextBox">
    <Setter
        Property="SelectionBrush"
        Value="#FFF8D172" />
    <Setter
        Property="Padding"
        Value="0" />
    <Setter
        Property="VerticalContentAlignment"
        Value="Center" />
    <Setter
        Property="FontSize"
        Value="9pt" />
    <Setter
        Property="SelectionOpacity"
        Value="0.6" />
</Style>

<DataGridTextColumn
   x:Name="TextColumn"
   Header="Header"
   EditingElementStyle="{StaticResource ResourceKey=DataGridTextBoxStyle}"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top