Regarding this post on how to embed custom controls in a XamDataGrid, I am having some problems when I want to modify it to do the following:
When I enter edit mode in PreviewKeyDown, the OnKeyDown override is called in the ControlHostEditor (ValueEditor) but this key stroke does not get propagated to the control in the EditTemplate. As a result, the value is not replaced and the previous value remains.
I would have expected the masked editors (xamMaskedEditor, xamNumericEditor, xamDateTimeEditor) to work since it is that element itself which is handling the TextInput event (i.e. its processing the key event). If it worked for the xamTextEditor then it may be possible to get this to work with the other editor since the xamTextEditor uses the TextBox within its edit template to handle processing the key/textinput events.
I looked at this quickly and from snoop it appears that the focused control is getting the key stroke so it should work. However, the problem seems to be that the binding is resetting the text to the value from the source object (i.e. wpf's evaluation of the binding is happening after the typed in value is provided). I've attached a modified version of the ControlHostEditor which doesn't use a FindAncestor and therefore doesn't suffer from this "delayed" binding evaluation in the wpf framework. When I get a chance I'll update the sample on the blog as well.
Thats fair, but why does entering edit mode in the PreviewKeyDown work for standard ValueEditors but not a custom value editor. Is there any special handling built into Infragistics code for these standard edtiors?
The WPF framework controls the raising of the key events. I would think that the element for which it raises the Preview event (PreviewKeyDown in this case) is the one for which it will raise the bubble event (KeyDown in this case). There isn't anything that we can do to control that. You would probably need to interpret the key action or handle it and try to do a send keys or something to simulate the key stroke so the new FocusedElement will receive the key events.