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
close icon

DataGrid nested in TabItem does not render when ItemSource only contains a single item


I have a WPF page when the standard WPF TabItem that contains SfDataGrid. The item source is bound to an ObservableCollection. When I select the tab that contains the SfDataGrid, it does not render on the screen unless there is at least 2 items in the item source collection. Below is the XAML for the TabItem containing the grid view.

<TabItem x:Name="WeldsTab"
                                <TextBlock Text="Welds" />
                            <StackPanel Margin="20,20,15,0">
                                <sfGrid:SfDataGrid x:Name="WeldsGrid"
                                                   ItemsSource="{Binding CurrentIsometric.Welds}"
                                                   SelectedItem="{Binding SelectedWeld, Mode=TwoWay}"
                                        <sfGrid:GridCheckBoxColumn MappingName="DeleteWeld"
                                        <sfGrid:GridCheckBoxColumn MappingName="VoidWeld"
                                        <sfGrid:GridTextColumn MappingName="ShopWeldFieldWeld" 
                                        <sfGrid:GridTextColumn MappingName="WeldClass" 
                                                            HeaderText="Weld Class"
                                        <sfGrid:GridTextColumn MappingName="WeldNumber" 
                                                      HeaderText="Weld No."
                                        <sfGrid:GridTextColumn MappingName="SpecificationNumber" 
                                                          HeaderText="Spec No."
                                        <sfGrid:GridTextColumn MappingName="WeldType" 
                                                      HeaderText="Weld Type"
                                        <sfGrid:GridTextColumn MappingName="Grade" 
                                        <sfGrid:GridTextColumn MappingName="PNumber" 
                                        <sfGrid:GridNumericColumn MappingName="PipeDiameter" 
                                                     HeaderText="Dia. Inches"
                                        <sfGrid:GridTextColumn MappingName="Schedule" 
                                        <sfGrid:GridTextColumn MappingName="Welder"

                                                    <TextBlock Text="{Binding Welder.RNumber}" />
                                                    <sfInput:SfTextBoxExt Style="{DynamicResource DefaultTextBox}"
                                                                          DataContext="{Binding ViewIsoViewModel, RelativeSource={RelativeSource Self }}"
                                                                          AutoCompleteSource="{Binding Welders.Name}"
                                                                          SelectedItem="{Binding Welder, Mode=TwoWay}" />
                                        <sfGrid:GridTextColumn MappingName="WeldDate"
                                                               HeaderText="Weld Date"
                                                               DisplayBinding="{Binding WeldDate, Converter={StaticResource shortDateConverter}}"
                                        <sfGrid:GridTextColumn MappingName="WpsNumber" 
                                        <sfGrid:GridTextColumn MappingName="PWHTCycle"
                                                               HeaderText="PWHT Cycle Temp/Time"
                                        <sfGrid:GridTextColumn MappingName="VisualCheck"
                                                               HeaderText="Visual Check"
                                        <sfGrid:GridTextColumn MappingName="InspectorId"
                                                               HeaderText="Inspector Id"
                                        <sfGrid:GridTextColumn MappingName="InspectionDate"
                                                               HeaderText="Inspection Date"
                                        <sfGrid:GridTextColumn MappingName="RadioGraphicTest"
                                                               HeaderText="Radiographic Test"
                                        <sfGrid:GridTextColumn MappingName="PtmtStatus"
                                                               HeaderText="MT/PT Test"
                                        <sfGrid:GridTextColumn MappingName="HardnessTest"
                                                               HeaderText="Hardness Test"
                                        <sfGrid:GridTextColumn MappingName="FitUpStatus"
                                                               HeaderText="Fit Up Status"
                                        <sfGrid:GridTextColumn MappingName="PreHeatTemp"
                                                               HeaderText="Pre-Heat/Interpass Temp"
                                        <sfGrid:GridTextColumn MappingName="MaterialType"
                                                               HeaderText="Material (SA)"
                                        <sfGrid:GridTextColumn MappingName="PWHTStatus"
                                                               HeaderText="PWHT Status"
                                        <Linq:SortComparer Comparer="{StaticResource WeldNumberSorter}" PropertyName="WeldNumber"/>
                                <TextBlock Text="{Binding UpdateSpoolsAndWeldsMessage}"
                                           Foreground="{Binding UpdateSpoolsAndWeldsMessageColor}"/>
                                <StackPanel Orientation="Horizontal" Margin="1272,0,0,0">
                                    <Button Command="{Binding AddWelds}" 
                                        Style="{DynamicResource DefaultActionButton}"
                                        Content="Add Welds"
                                    <Button Command="{Binding UpdateWeldsAndSpools}"
                                            Style="{DynamicResource DefaultActionButton}"
                                            Content="Save Changes"

4 Replies

SV Srinivasan Vasu Syncfusion Team August 16, 2016 12:43 PM UTC

Hi Brandon, 
Thank you for contacting Syncfusion support. 
We have analyzed your query. We are not able to reproduce the reported “SfDataGrid nested in TabItem does not render when ItemSource only contains a single item” 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 Location: SfDataGridFiltering 

BH Brandon Hankins August 16, 2016 02:30 PM UTC

I will not be able to modify the example to reproduce since it requires an external data source contained within our network. I can attempt to explain the scenario below.

Here is the flow of the application to get to the point where the SfDataGrid fails to render properly:

1. User selects a Project and is taken to a project page that has a list of Isometric drawings
2. User selects which drawing they would like to view data for and clicks Open
3. User is taken to the Isometric details page which contains two tabs each with a SfDataGrid. To get the data we pass the Isometric ID to the Page contstructor, use that ID to query the database asynchronously for the proper Isometric data. We then pass that Isometric data into the ViewModel constructor. The Page DataContext is set to the new ViewModel in the Page.cs.

For whatever reason, when there is only 1 item in the non-visible tab it does not render. If I take both grids out of the Tab control and stack them on the page vertically, they both render properly. If I use the same data and bind to the standard C# DataGrid control, it renders inside the tab fine.

BH Brandon Hankins August 16, 2016 05:30 PM UTC

I have resolved the issue. I was overriding the template in App.xaml in order to globally set border colors and something was inadvertently changed when I copied the default template in Blend.

Sorry for the inconvenience.


SV Srinivasan Vasu Syncfusion Team August 17, 2016 02:23 AM UTC

Hi Brandon,

Thanks for your update.

Live Chat Icon For mobile
Up arrow icon