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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Overriding items source of SfDataGrid.

Thread ID:

Created:

Updated:

Platform:

Replies:

140781 Nov 7,2018 05:13 AM UTC Nov 13,2018 12:21 PM UTC WPF 1
loading
Tags: SfDataGrid
Vasudeva Naik
Asked On November 7, 2018 05:13 AM UTC

Hi,
I am trying to override the metadata of SfDataGrid with following code:
public class AdvancedGrid : SfDataGrid
…..
ItemsSourceProperty.OverrideMetadata(typeof(AdvancedGrid), new FrameworkPropertyMetadata(OnItemsSourceChanged));
….
private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is AdvancedGrid grid)
{
grid.HandleItemsSourceChanged(e.OldValue, e.NewValue);
}
}
Please note I have triedPropertyMetadata and UIPropertyMetadata too for passing in metadata details.
Everytime I am ending in exception:
{"Metadata override and base metadata must be of the same type or derived type."}

Shobika Palani [Syncfusion]
Replied On November 13, 2018 12:21 PM UTC

Hi Vasudeva 
 
We have analyzed your query to override metadata of SfDataGrid from our end. We have used GridPropertyMetadata type in our source for ItemsSourceProperty. Because of this only exception raises. So you can resolve this exception by using GridPropertyMetadata instead of FrameworkPropertyMetadata,. Please refer below code snippet  
 
public class CustomSfDataGrid : SfDataGrid 
    { 
        public CustomSfDataGrid() 
        { 
            ItemsSourceProperty.OverrideMetadata(typeof(CustomSfDataGrid), new GridPropertyMetadata(null, OnItemsSourceChanged)); 
        } 
 
        public static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) 
        { 
            //You can write your own code here. 
        } 
    } 
 
Please let us know if you need further assistance on this. 
 
Regards, 
Shobika. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon