This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi I have a scenario where I have a combobox as an editor in a DataGrid. Instead of having the combobox appear when the user clicks on a cell, I would like the combobox to always be visible, this way the user can expand the combobox with a single click to change the value of the cell. I have attempted to use a combobox in the DisplayTemplate instead of the EditTemplate but the combobox loses focus when the mouse is moved outside the bounds of the cell. Is this currently possible to achieve? Thanks Chris |
|
|
Hello Chris The DisplayTemplate and EditorTemplate will need different bindings to the selected value. The DataContext of the display template is the model object of the row. So here, the binding to the selected value of the ComboBox will be a binding to the appropriate property on your model objects. The binding in the editor template on the other hand will need to be {Binding Value}. In other words you need a different template for display mode and edit mode, each with the appropriate binding. I have noted this down as something to improve in the next version. Let me know if you need help with setting these different templates. Please note that having a ComboBox always visible in all cells of a column can effect the performance of the data grid. It will be best not to do this to too many columns within the same data grid. Another thing you could do is set the DataGrid.CellEditModeBehavior property to OnClick. This will put the cell into edit mode on a single click. Jason Fauchelle |
|
|
I have attached an image of what I am trying to achieve. I have an editable combobox as the editor for a column in the grid. Even with the CellEditModeBehavior set to OnClick, it still takes two clicks to either edit the text or expand the dropdown if the button is clicked. Setting no edit template but using the combobox in the displaytemplate almost offers the behaviour I am after except that the combobox loses focus if the mouse pointer moves outside the bounds of the cell. If I could obtain a reference to the editor control (combobox) when a cell is selected then I could force the combobox to expand in code-behind. Is this possible? Thanks Chris |
|
|
Hello Chris In the next nightly build you'll find the DataGridColumn.IsAlwaysInEditMode property. Set this property to true on your combo box columns to always display the editor. Note: It's best not to set this to true on too many columns. As I mentioned previously, the existence of too many editors at once can effect the performance. Jason Fauchelle |
|