I am making a user control (view) that mimics windows explorer in detail view.
I use a TreeView control for the tree navigation (on the left) and a XamDataGrid for the details view of files (on the right).
When adding files or folders I would like the row to immediatley enter edit mode. E.g. when adding a folder in windows explorer, the folder is created and the curser flashes in the Name column waiting for the user to rename the New Folder to something useful. How do I do that in the XamDataGrid - Force the XamDataGrid to enter edit mode on the new row?
Thanks in advance for your help!
Infragistics support has come back to me saying I should use the StartEditMode Command. Problem is I am using the MVVM model. How would I invoke this command and the command on my viewmodel when adding a new item to the datasource? There doesn't appear to be an editmode property on the grid.
Support example: this.XamDataGrid1.ExecuteCommand(DataPresenterCommands.StartEditMode);
My context menu on my XamDataGrid.
<igDP:XamDataGrid.ContextMenu> <!-- Grid Context Menu --> <ContextMenu> <MenuItem Command="{Binding AddNewCommand}" CommandParameter="Document" Header="New Document" /> <MenuItem Command="{Binding AddNewCommand}" CommandParameter="Folder" Header="New Folder" /> </ContextMenu> </igDP:XamDataGrid.ContextMenu>
Hi,
I'm researching this for you and will post back here as soon as I have more information.
I found a number of articles, blogs, threads that I think will help you.
The first two are explaining the theory behind binding commands back to the viewmodel from tooltips or contextmenus .
Excellent article by JoshSmith: Using RoutedCommands with a ViewModel in WPF, includes sample
http://www.codeproject.com/KB/WPF/VMCommanding.aspx
Andrew Smith has an excellent blog post on the subject (also with sample)
http://agsmith.wordpress.com/2008/07/17/elementname-binding-in-tooltips-borrowing-a-namescope/
This is the most straight forward resolution to the issue I believe you are having. From the contextMenu you need to get access to the viewmodel that is bound to the grid.
http://community.infragistics.com/forums/t/48640.aspx
It shows how to use relativeSource in the binding path so that the Command is pointed to the xamDataGrid instead of the ContextMenu.
<Setter Property="MenuItem.Command" Value="{Binding Path=DataContext.InvokeActionCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:XamDataGrid}}}"/>
Please let me know if you have further questions
I hadn’t heard back from you and I am checking to see if you had any further questions.
Please let me know if there is anything I can help with.