I replaced the template of a CellValuePresenter, and added a CheckBox as my template,
I did this in order to receive change events when the user checks/unchecks rather than having to
move to a new row.
This is what I have:
<ig:FieldSettings.CellValuePresenterStyle>
<
Style TargetType="{x:Type ig:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<CheckBox HorizontalAlignment="Center" VerticalAlignment="Center"
IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}"/>
</
ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ig:FieldSettings.CellValuePresenterStyle>
So, this solved my problem of receiving the events in a timely fashion, But, I am having problems with
Keyboard interaction, If I tab into a field which uses the above style, the checkbox doesn't have the focus
instead the focus is on the cell value presenter. How do I make this work?
Instead of retemplating the CellValuePresenvet to go around this, you can just handle the ValueChanged event of the checkbox (either with EventSetter in a style or with the EventManager.RegisterClassHandler() method) and force the editor to end its edit mode by calling its EndEditMode() method.
So, I have other reasons why I want to retemplate the CellValuePresenter, Styling being one of them, we have a set of 3rd party styles which change the app's look, Since the styles we use have no notion of what a XamCheckEditor is, I prefer to use the retemplating approach.
Is there no way to prevent the CellPresenter from getting Focus?
You can try this approach :
http://blogs.infragistics.com/blogs/andrew_smith/archive/2009/03/27/hosting-wpf-controls-in-a-xamdatagrid-cell.aspx