We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Example of Problem with Binding to User Control


I've got a usercontrol (InspectionItemPresenter) configuration that I can not bind correctly to the SFDataGrid, but works with a ListView.  

I made a copy of my control (InspectionItemPresenter2) and modified it to accept the entire object instead of binding the parts separately and with that I can show data in my grid, but because of the way I had to set context (to make the grid data show) in the user control constructor my DataContext is the user control itself which is BAD...I need data in the grid AND  the InspectionItem object as the DataContext. 

Please run the example and see that the InspectionItems bind directly to the UserControl and  try to help me get the DataGrid to show this as well.  The current setup will throw a few exceptions (complaining about the DAtaContext being the wrong type), but you will be able to see the desired result in the ListView.

There are several extra files in the solution that can be ignored.  I'm pressed for time or I would have cleaned it up for you.  Sorry about the inconvenience.

thanks!
Deanna

Attachment: UserControlBindingProblem_394ef88b.zip

1 Reply

JS Jayapradha S Syncfusion Team April 14, 2016 12:41 PM UTC

Hi Deanna,

Thank you for contacting Syncfusion Support.

We have analyzed your reported issue with your sample. We found that you have used the different collection for SfDataGrid and ListView. In ListView, you have used PointDataSequential as ItemsSource and it is collection of InspectionItem. So that InspectionItemPresenter can get the required property values from InspectionItem class. But in the case of SfDataGrid Points2 is the itemssource which is the collection of PointTestClass. So the datagrid item template couldn’t get the required properties.

Please modify the SfDataGrid itemssource to PointDataSequential like list view. It is working fine.

Regards,
Jayapradha


Loader.
Live Chat Icon For mobile
Up arrow icon