I have a scenerio in MVVM where I have a datagrid user control that will be used on several different pages and within the control if the everytime the datasource changes I want to set the Active record to the ActiveDataItem or the the first record if the ActiveDataItem is null. I'm having trouble trying to set the ActiveDataItem to the Active Record and setting it to ISselected. Below I have a demo.
Hello,
Here you can find more information about the DataContext and how it works:
http://www.wpf-tutorial.com/data-binding/using-the-datacontext/
Hope this helps you.
Can you bind to DataContext like you do DataSource because I couldn't get it to work.
If you change the DataContext, yo ucan handle the XamDataGrid's DataContextChanged event.
Is there another event I can use like a DataSource override event? Because with InitializeRecord event it can take a long time to populate the data if I'm wokring with thousands of records. I was looking for an event that'll get called everytime the the DataSource changes and not have to be called for every record.
Thank you for your post. I have been looking into it and I modified the sample you sent us, so now it work as you want. Basically I changed the way the DataSource is set, because the SelectedPerson was set two early, before the XamDataGrid initializes its Records. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.