Hi,
I would like to select a Cell in xamDataGrid in CodeBehind just like if i would click on it.
I tried the following commands:
dg_Kunden.Records[0].IsSelected = true;dg_Kunden.ActiveRecord = dg_Kunden.Records[0];dg_Kunden.ExecuteCommand(DataPresenterCommands.RecordFirstDisplayed);
but no command achieves the behavior I would like to have.
1. I have a triggerd the SelectionChanged Event of the Grid. If I Select a Cell in the GUI the Event triggers. With the commands, the Event doesn't triger.
2. I have WPF-Labels with a Binding on the ActiveRecord of the Grid. But with the Commands the Value doesn't change.
Content="{Binding ElementName=dg_Kunden, Path=ActiveRecord.Cells[KU_Name3].Value}"
Can you immagine what I am doing wrong?
Hello Alex,
Thank you for your example. This is what i would like to achiev. And now I know why it didn't work for me. My Binding was correct and my executecommand() was correct too. But the time I did it was wrong. I called the executecommand direct after updating the defaultview of the datasource and I think at this Time the Grid wasn't rendered and updated completely.
No I have done a workarround for this by triggering the LayoutUpdated-Event and setting the executecommand in there. Now it works
Hello Thomas,
There is a difference between the ActiveRecord and SelectedRecord. The ActiveRecord is the last record that you have selected - the one that has the black arror (record selector) in from of it. This is to what you have bound the labels. The SelectedRecord may not necessarily be the ActiveRecord, so you should have that in mind too.
I am attaching a small project. Please take a look at it and let me know if that is what you are trying to achive.