ItemDisplayBindingPath + NullReferenceException

2 posts, 0 answers
  1. Travis
    Travis avatar
    1 posts
    Member since:
    Sep 2019

    Posted 09 Sep 2019 Link to this post

    I am attempting to use a DataGridPickerColumn. I am able to get my source list to show up and also have it bind to my property, but whenever I use the ItemDisplayBindingPath, the app is crashing with a null reference exception. Whenever I take out ItemDisplayBindingPath, I do not get the exception. My ProductModel class and the XAML I am using is below:

     

    public class ProductModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Units { get; set; }
    }

     

    <tkDataGrid:DataGridPickerColumn ItemsSource="{Binding BindingContext.Data.ProductModels, Source={x:Reference schedulePage} }" ItemDisplayBindingPath="Name" PropertyName="Product" HeaderText="Product" />

  2. Yana
    Admin
    Yana avatar
    5040 posts

    Posted 11 Sep 2019 Link to this post

    Hi Travis,

    I've tested the scenario and managed to reproduce the exception - it seems there is an issue in RadDataGrid in the case the ItemsSource of the PickerColumn is bound to a collection not part of the business object. I logged the issue on your behalf in our public feedback portal, you could track its status and get notified on status changes at the link below:

    DataGrid: NullReferenceException is thrown when ItemsSource of the PickerColumn is bound to an external source

    There isn't a direct workaround I could suggest for the concrete setup - the options that come to my mind are:

    • Use DataGridTemplateColumn instead of the PickerColumn and manually add a Picker control. Keep in mind that the TemplateColumn has some limitations such as missing filtering feature. Check the following article for more details on this: DataGrid TemlateColumn.
    • Use ItemsSourcePath property of the PickerColumn, this, however, will require adding the ProductModels collection as a property of the business objects used as ItemsSource of the DataGrid.  Please check the exact implementation here: DataGrid Columns Example.

    I am sorry for any inconvenience caused.

    Regards,
    Yana
    Progress Telerik

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top