How to restyle TextBox of DataGridTextColumn?
-
28-10-2019 - |
문제
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.
해결책
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}"/>