I have a class that inherits from XamDataGrid to specialize it for our application. It is data bound by setting its DataSource to a ViewModel property which fires OnPropertyChanged on its setter. All standard MVVM pattern.
Now I would like to do something after the data source has changed and the grid has finished databinding. I only want to do my action once and only after data binding is finished. I don't want to do it in the ViewModel, but in my specialized XamDataGrid class. So I was looking for an event that fires when data binding is finished. I would guess this is a common WPF scenario, but I cannot find that event.
Any help is much appreciated.
Hello Prakash,
I have been looking into the sample you have attached and I can say that since there is a virtualization of the DataRecordPresenter, the same elements are used and this is the reason why the Loaded event is not fired. I am also wondering why do you need this event and isn't possible for you to execute the code you need after you set the DataSource. Also could you please give me more details about the functionality you want to achieve?
Looking forward for your reply.
Forgot to attach the sample project.. Here is I am attaching the sample project.
Hi,
I have a similar requirement , the thing I need is when ever I do databind a different collection then the Load event should fire. I have used your code to modify to get this functionality but the issue I am seeing , First time Load event got fired, then after the button click to load a different collection , first time load fires but the Record.Index > 0 (always) so it never goes inside If
Also if I click the button load one more time It never fires the load event.
I like to
1. When ever I do bind different data collection it should fire load event
2. After second time onwards it should go inside the if statement.
Regards,
Prakash.G
Hello,
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking into your post and I created a sample project for you with the functionality you want. Basically I handled the DataRecordPresentrer’s Loaded event and do Action when the Binding is finished.
Feel free to write me if you have further questions.