Inheriting from SfDataGrid crashes on constructor
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?
SIGN IN To post a reply.
5 Replies
SV
Srinivasan Vasu
Syncfusion Team
February 13, 2017 08:52 AM UTC
Hi Emmanuel,
Thanks for contacting Syncfusion support.
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.
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/SfDataGridDemo-1369163153.zip
Regards,
Srinivasan
EO
Emmanuel Onyeje
February 14, 2017 05:20 AM UTC
Hi Srinivasan,
Attachment: MainPage_3cca229e.zip
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
GT
Gnanasownthari Thirugnanam
Syncfusion Team
February 15, 2017 01:38 PM UTC
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.
EO
Emmanuel Onyeje
February 15, 2017 08:19 PM UTC
HI Gnanasownthari,
Thanks for the response. If this code resides in a class library and not an executable how would i go about it?
GT
Gnanasownthari Thirugnanam
Syncfusion Team
February 16, 2017 01:26 PM UTC
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.
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
-
EO Emmanuel Onyeje
- Feb 11, 2017 01:15 AM UTC
- Feb 16, 2017 01:26 PM UTC