Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
605
Select a Cell in CodeBehind
posted

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?

Parents
  • 69686
    posted

    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.

    WpfApplication10.zip
Reply Children
No Data