Hi there
We got a problem with the AddNewRecord funtionality of the xamDataGrid.
On some cells, we're showing a button to the user. When the user clicks the button, another window is shown with whatever content. Then the user can select an option in this window, and the value is getting written back to the underlying dataitem. Everything is working fine on a record, where the underlying dataitem is already there. But when the user is in the AddNew-Row, and he starts typing or directly clicks the button, in this specific cell with the button, the xamDataGrid is not instanciating a new underlying dataitem. Therefore, our application does not work as expected.
I have created a small sample application, where you can exactly see, what our problem is.
The underlying dataitem 'Entry' has 3 properties. 'Age', 'LastName' and 'Name'. On 'Age' and 'LastName' everything is working as expected. But on 'Name' (where i have attached the Style for the CellValuePresenter), the constructor is not getting called, when the user starts typing or is clicking the button.
Can you help me with that? We need the same behavior, which a cell has without that style when a user starts typing. Also the same behavior, when the user clicks the button, as he would start typing.
Hi Christian,
The Entry class is being instantiated when the cell editor value changes. There is a specific editor type (ValueEditor) that the cell is looking for and currently your CellValuePresenter style template doesn't have this editor. So the simplest thing you could do is add the appropriate ContentPresenter with the correct x:Name so that the cell can find it and insert the desired ValueEditor. Replace your TextBox with this:
<ContentPresenter x:Name="PART_EditorSite" Grid.Row="0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" Style="{TemplateBinding ForegroundStyle}"/>
You can still have all the other custom stuff inside the CellValuePresenter template, but our code is specifically looking for a PART_EditorSite so it can insert a ValueEditor (XamTextEditor, XamNumericEditor, etc).
This should give you the same behavior as the other cells that don't have any styling.
Ok, figured out, how to make it work with our described value box. I exchanged the internally used TextBox with a xamTextEditor. Then everything is working fine, when a user starts typing. Check the updated, attached sample.
But, now i'm stuck with the button. How to raise the 'EditModeStartingEvent' which i found in the abstract class Infragistics.Windows.Editors.ValueEditor? Or something similiar to put the cell in EditMode when the user clicks the button instead of starting typing...
Hi Rob
Thank you for your answer. This solves the issue, when a user is typing something in the field. But what about, when the user clicks the button in the cell, before he typed anything? (Like StartEditMode) Can you get me some advice on this also please?
Also, usually we're using a custom editor, which displays a text for the key a user entered. Like the user enters 37823, and the editor displayes a short description for it. Do i have to implement a special version for the xamDataGrid for this? Or how do i put this in this ContentPresenter?
Regards
Chris