I need to show a textbox in the DataGrid, so users know which columns are editable. Currently, I am customizing the CellValuePresenter. However, if I don't customize the EditorStyle to be a textbox, then I don't receive the EditStarting, EditStarted, EditEnding, EditEnd events from the datagrid. I need those events, therefore I have both styles for the CellValuePresenter and the EditorStyle override.
Ideally, I would like a way to show the textbox by specifying only the Editor Style. Is this the best way or is my way the recommended way? Do you have any suggestions?
Here are my customized styles
<Style TargetType="{x:Type ig:CellValuePresenter}" x:Key="PresenterStyle"> <Setter Property="Foreground" Value="Transparent"/> <Setter Property="ForegroundStyle"> <Setter.Value> <Style/> </Setter.Value> </Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ig:CellValuePresenter}"> <Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"> <TextBox HorizontalContentAlignment="Center" Margin="1" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" /> <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" x:Name="PART_EditorSite" Style="{TemplateBinding ForegroundStyle}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}"/> </Grid> </ControlTemplate> </Setter.Value> </Setter></Style><Style TargetType="{x:Type igEditors:XamTextEditor}" x:Key="EditorStyle"> <Setter Property="EditTemplate"> <Setter.Value> <ControlTemplate> <Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"> <TextBox HorizontalContentAlignment="Center" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" /> </Grid> </ControlTemplate> </Setter.Value> </Setter></Style>
Please follow this link here.