Hello
What I'm trying to do, and cannot find the way, is that I want to have 2 buttons on the toolbar:
1. Paste
2. Paste new rows
The functionality is preety straightforward. I've implemented the first by:
<MenuItem Header="Paste" Command="{x:Static igDP:DataPresenterCommands.Paste}" CommandTarget="{Binding ElementName=MyGrid}" />
However, I cannot find the way to implement 2nd option (in that case, the behaviour should be the same as If I select the "add new record" indicator and clicked paste).
I tried to combine these 2 commands, simply by selecting the first record. But first record is not the "Add record" indicator, but first data record.
How could I implement this?
Thx in advance.
HI ,
I created a sample XamDataGrid application and implemented a special command to PasteNewRow.
Please review my sample.
Sincerely,
Matt Developer Support Engineer
Thanks Matt! This is exactly what I needed!
Just for the record:
Solution from the sample sometimes fails. It happened that instead of "Add record" row to be highlighted just before paste was executed, the Filter record was highlighted. In that case, clipboard content was pasted into Filter record, which started to filter grid content.
I've modified a bit the solution, and following seems to work perfectly:
public class XamDataGridPasteNewRowsCommand : ICommand { public bool CanExecute(object parameter) { return true; } public event EventHandler CanExecuteChanged; public void Execute(object parameter) { var xg = parameter as XamDataGrid; xg.ExecuteCommand(DataPresenterCommands.RecordFirstOverall); xg.ExecuteCommand(DataPresenterCommands.RecordAbove); xg.ExecuteCommand(DataPresenterCommands.Paste); } }