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.
Unfortunately, activation email could not send to your email. Please try again.

Inheriting from SfDataGrid crashes on constructor

Thread ID:

Created:

Updated:

Platform:

Replies:

128823 Feb 10,2017 08:15 PM Feb 16,2017 08:26 AM UWP 5
loading
Tags: SfDataGrid
Emmanuel Onyeje
Asked On February 10, 2017 08:15 PM

Hi,

I am trying to create a customized version of the SfDataGrid to do some customised column building. I created a simple class like this

class NewGrid : SfDataGrid
{
}

no extra properties no extra code and when i tried to instantiate one the app crashes and even Visual Studio cannot catch the exception. I have also seen this with SfNumericTextBox. The solution i had with SfNumeric was to wrap as an member in a generic class and expose the new properties and methods in the new class. That has not worked for me with SfDataGrid. Is there something about not supporting inheritance or encapsulation for Syncfusion controls?

Srinivasan Vasu [Syncfusion]
Replied On February 13, 2017 03:52 AM

Hi Emmanuel,


Thanks for contacting Syncfusion support.
 
 
We have checked your query. We are not able to reproduce the reported “Application Crash” issue. For your reference we have attached the tested sample in the below sample location, please revert by modifying the attached sample based on your application along with the replication procedure. It will be helpful for us to analyze further.  

Regards,
Srinivasan 


Emmanuel Onyeje
Replied On February 14, 2017 12:20 AM

Hi Srinivasan,

Thanks for the demo solution. When i ran your solution i did not get the error. However i felt you may not be completely reproducing my scenario. hence i commented out the NewGrid in the XAML file and recreated it within the MainPage constructor as code below as this more simulates how i am using your library. I got an unhandled exception ( "No installed components were detected. (Exception from HRESULT: 0x800F1000)") with Message "Cannot apply a Style with TargetType 'Syncfusion.UI.Xaml.Grid.SfDataGrid' to an object of type 'Windows.UI.Xaml.Controls.Control'.".

    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();

            datagrid = new NewGrid
            {
                ColumnSizer = GridLengthUnitType.Star,
                AutoGenerateColumns = true,
                NavigationMode = NavigationMode.Cell,
                AllowEditing = true,
                AutoGenerateRelations = false,
            };
            datagrid.SetBinding(SfDataGrid.ItemsSourceProperty, new Binding {Path = new PropertyPath("OrderInfoCollection")});
            datagrid.Columns.Add(new GridTextColumn
            {
                MappingName = "OrderID",
                HeaderText = "Order ID",
            });
            datagrid.Columns.Add(new GridTextColumn
            {
                MappingName = "CustomerID",
                HeaderText = "Customer ID",
            });
            datagrid.Columns.Add(new GridTextColumn
            {
                MappingName = "CustomerName",
                HeaderText = "Customer Name",
            });
            datagrid.Columns.Add(new GridTextColumn
            {
                MappingName = "Country",
                HeaderText = "Country",
            });
            datagrid.Columns.Add(new GridTextColumn
            {
                MappingName = "ShipCity",
                HeaderText = "Ship City",
            });
            grid.Children.Add(datagrid);
        }

        private SfDataGrid datagrid;
    }


Attachment: MainPage_3cca229e.zip

Gnanasownthari Thirugnanam [Syncfusion]
Replied On February 15, 2017 08:38 AM

Hi Emmanuel, 
  
We are able to reproduce your reported Exception “unhandled exception ( "No installed components were detected. (Exception from HRESULT: 0x800F1000)") with Message "Cannot apply a Style with TargetType 'Syncfusion.UI.Xaml.Grid.SfDataGrid' to an object of type 'Windows.UI.Xaml.Controls.Control'”  but it is  framework level issue, But you can overcome this issue by using below code sample in your application. 
  
XAML: 
<Application.Resources> 
        <Style TargetType="local:NewGrid"/> 
    </Application.Resources> 
  
We have modified the sample, you can download the same from below mentioned location. 
  
Sample location: 
  
Regards, 
Gnanasownthari T. 
 


Emmanuel Onyeje
Replied On February 15, 2017 03:19 PM

HI Gnanasownthari,

Thanks for the response. If this code resides in a class library and not an executable how would i go about it?

Gnanasownthari Thirugnanam [Syncfusion]
Replied On February 16, 2017 08:26 AM

Hi Emmanuel,  

We have analyzed your query, in your class library you can write style in Generic.xaml for derived NewGrid like below code and you can add the class library in your application. 
 
<ResourceDictionary 
    xmlns:local="using:UWPClassLibrary"> 
    <Style TargetType="local:Newgrid"/> 
</ResourceDictionary> 

We have prepared the class library and sample for your requirement, you can download the same from below mentioned locations 

Class library location: 

Sample location: 

If your requirement is differ from above, please share more details about your query. It will helpful for analyze further on this. 

Regards, 
Gnanasownthari T. 


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.

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.

;