Is there a way to use the DataPresenterExcelExporter with MVVM? The export method requires an instance of an object that has DataPresenterBase as the base class. In my case I'm using a xamDataGrid. I'm also using the MVVM Light toolkit as a side note. Is there a way to pass the xamDataGrid object reference to my view model?
This is what you would do in the code behind:
DataPresenterExcelExporter exporter = (DataPresenterExcelExporter)this.Resources["Exporter"];
exporter.Export(xamDataGridInstance, excelSheet);
Hello KrisVice,
Thank you for your post!
While I am not entirely familiar with the MVVM Light toolkit, the simplest way that I can think of to export your XamDataGrid to Excel in an MVVM fashion is through the usage of an ICommand. If you give the XamDataGrid a name and bind to it using an ElementName binding for the CommandParameter property of the element that you attach the command to, you can pass your instance of your XamDataGrid that way.
I have attached an example where I hook an ICommand to a Button's Command property and pass the XamDataGrid to the command via the CommandParameter property on the button. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support