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

SfDataGrid inside DataTemplate causes NullReferenceException at runtime

Trying to put SfDataGrid inside TabControlExt.ContentTemplate

<sf:TabControlExt Grid.Row="1" ItemsSource="{Binding Tabs}" DisplayMemberPath="Header">
     <sf:TabControlExt.ContentTemplate>
          <DataTemplate>
               <sf:SfDataGrid ItemsSource="{Binding GridSource}"/>
          </DataTemplate>
     </sf:TabControlExt.ContentTemplate>
</sf:TabControlExt>

I attached stacktrace from runtime exception

When I use standard DataGrid, everything runs fine.
Is this bug? Or maybe I'm doing something wrong?



Attachment: sfdatagridnullreferenceexception_5d6d5768.zip

6 Replies

SS Steve Schmutzler September 3, 2017 09:28 AM UTC

Hello Konstantin,

did u check it with AutoGenerateColumns="False"?

Best regards

Steve



KO Konstantin September 3, 2017 09:50 AM UTC

Hello, Steve.

Just checked with AutoGenerateColumns="False". The same exception occurs.



KO Konstantin September 4, 2017 08:40 AM UTC

I believe, I found the reason for this exception happening

Please find attached xaml.

Commented sections caused this.

Is there any way to use styles in this scenario?


Attachment: working_19cdf21d.zip


KJ Keerthana Jegannathan Syncfusion Team September 6, 2017 09:53 AM UTC

Hi Konstatantin, 
 
Thank you for contacting Syncfusion support. 
 
We have checked the reported behavior of Ribbon based on your updated Xaml code and we were unable to reproduce the NullReference exception from our side. We have prepared a simple sample for your reference and it can be downloaded from the below location. 
 
 
Can you check with the above sample for the scenario we have checked and let us know if we have misunderstood your query. Also, as you mentioned that the commented out the resource file can resolve your exception, we request you to apply the resource dictionary in app.Xaml and update whether the issue can be reproduced. If still the issue persists, can you modify the sample which replicates the issue? That will helps us to analyze and provide the solution at earliest. 
 
Regards, 
Keerthana J 



KO Konstantin September 7, 2017 10:59 AM UTC

Hello,

I applied ResourceDictionary in App.xaml, everything runs without exceptions from now.

Thank you.



KJ Keerthana Jegannathan Syncfusion Team September 8, 2017 04:16 AM UTC

 Hi Konstatantin,


Thanks for your update.


Please let us know if you need further assistance on this.


Regards,

Keerthana J
 


Loader.
Up arrow icon