This is a migrated thread and some comments may be shown as answers.

NullReferenceException GridView

6 Answers 124 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 09 Jan 2012, 01:49 PM
Hi,

We are currently having issues running our application on Windows 7 tablet PC's. When the grid has data, we get a NullReferenceException. I found it that the exception will not occur when removing a specific column definition from the gridview:

  <telerik:GridViewColumn     CellTemplate="{StaticResource StatusButtons}"
                                            IsFilterable="False"
                                            MaxWidth="120"
                                            MinWidth="120"
                                            />

The application works fine on non-touch devices, but on touch devices (Win 7, .Net 3.5) the error occurs. Stopping the "Tablet PC Input" service does not help as mentioned in other threads.

The exception plus stacktrace

2012-01-09 10:09:18,868 FATAL - User Interface : Unhandled Exception
System.NullReferenceException: De objectverwijzing is niet op een exemplaar van een object ingesteld.
   bij System.Windows.Automation.Peers.AutomationPeer.EnsureChildren()
   bij System.Windows.Automation.Peers.AutomationPeer.UpdateChildren()
   bij System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   bij System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   bij System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   bij System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   bij System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   bij System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   bij System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   bij System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()
   bij System.Windows.ContextLayoutManager.fireAutomationEvents()
   bij System.Windows.ContextLayoutManager.UpdateLayout()
   bij System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   bij System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   bij System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   bij System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   bij System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   bij System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   bij System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)


The Xaml:
<UserControl x:Class="BrabantWater.UI.Screens.ZInspectionListScreen"
    xmlns:imageFactory="clr-namespace:Sap.Eam.UI.Theme;assembly=CustomTheme_WPF"
    Height="auto" Width="auto">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="boolToVisConverter"/>
        <DataTemplate x:Key="StatusButtons">
            <StackPanel Orientation="Horizontal" Width="110">
                <telerik:RadButton Click="RadButtonDelete_Click" MinWidth="50"
                                   IsEnabled="{Binding Path=IsDeletable, Mode=OneWay}">
                    <Image Source="{Binding Path=DeleteImage, Mode=OneWay}" Width="32"/>
                </telerik:RadButton>
                <telerik:RadButton Click="RadButtonStatus_Click" MinWidth="50"
                                   IsEnabled="{Binding Path=IsEditable,Mode=OneWay}">
                    <Image Source="{Binding Path=StatusImage, Mode=OneWay}" Width="32"/>
                </telerik:RadButton>
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    <Grid x:Name="GridContainer">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
 
        <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="5,5,5,5" Height="35" HorizontalAlignment="Stretch" VerticalAlignment="Center">
            <telerik:RadButton x:Name="ButtonNewInstallation" Content="{lex:LocText Key=Inspection_New_Installation, Dict=InspectionResources, Assembly=Win32Resources}" MinWidth="100" Click="ButtonNewInstallation_Click"/>
            <telerik:RadButton x:Name="ButtonNewDamage" Content="{lex:LocText Key=Inspection_New_Defect, Dict=InspectionResources, Assembly=Win32Resources}" Margin="10,0,0,0" MinWidth="100" Click="ButtonNewDamage_Click"/>
        </StackPanel>
                     
        <telerik:RadGridView x:Name="InspectionGrid"
                             AlternationCount="2"
                             AutoGenerateColumns="False"
                             CanUserFreezeColumns="False"    
                             CanUserReorderColumns="False"
                             ColumnWidth="*"
                             EditTriggers="None"
                             Grid.Row="1"
                             Margin="5"
                             MouseDoubleClick="InspectionGrid_MouseDoubleClick"
                             RowIndicatorVisibility="Collapsed"
                             SelectionChanged="InspectionGrid_SelectionChanged"
                             SelectedItem="{Binding Path=CurrentInspection, Mode=TwoWay}"
                             ShowGroupPanel="false">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn UniqueName="DamageCodeDescription"
                                            Header="{lex:LocText Key=Inspection_Space, Dict=InspectionResources, Assembly=Win32Resources}"
                                            DataMemberBinding="{Binding Path=DamageCodeDescription, Mode=OneWay}"/>
                <telerik:GridViewDataColumn UniqueName="ItemCodeDescription"
                                            Header="{lex:LocText Key=Inspection_Part, Dict=InspectionResources, Assembly=Win32Resources}"
                                            DataMemberBinding="{Binding Path=ItemCodeDescription, Mode=OneWay}"/>
                <telerik:GridViewDataColumn UniqueName="ItemDescription"
                                            Header="{lex:LocText Key=Inspection_Addition, Dict=InspectionResources, Assembly=Win32Resources}"
                                            DataMemberBinding="{Binding Path=ItemDescription, Mode=OneWay}"/>
                <telerik:GridViewDataColumn UniqueName="CauseCodeDescription"
                                            Header="{lex:LocText Key=Inspection_Task, Dict=InspectionResources, Assembly=Win32Resources}"
                                            DataMemberBinding="{Binding Path=CauseCodeDescription, Mode=OneWay}" />
                <telerik:GridViewDataColumn UniqueName="TaskCodeDescription"
                                            Header="{lex:LocText Key=Inspection_Finding, Dict=InspectionResources, Assembly=Win32Resources}"
                                            DataMemberBinding="{Binding Path=TaskCodeDescription, Mode=OneWay}" />
                <telerik:GridViewDataColumn UniqueName="ActivityCodeDescription"
                                            Header="{lex:LocText Key=Inspection_Risk, Dict=InspectionResources, Assembly=Win32Resources}"
                                            DataMemberBinding="{Binding Path=ActivityCodeDescription, Mode=OneWay}" />
                <telerik:GridViewImageColumn DataMemberBinding="{Binding Path=AttachmentImage, Mode=OneWay}"
                                            Header="{lex:LocText Key=Inspection_Attachments, Dict=InspectionResources, Assembly=Win32Resources}"
                                            ImageHeight="32"
                                            ImageWidth="32"
                                            IsFilterable="False"
                                            MaxWidth="60"
                                            MinWidth="60"
                                            />
                <telerik:GridViewColumn     CellTemplate="{StaticResource StatusButtons}"
                                            IsFilterable="False"
                                            MaxWidth="120"
                                            MinWidth="120"
                                            />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>     
    </Grid>
</UserControl>

The version of the Telerik WPF components being used: 2010.2.0716.35.

How can we solve this issue?

Kind regards,

Mike

6 Answers, 1 is accepted

Sort by
0
Mike
Top achievements
Rank 1
answered on 10 Jan 2012, 07:38 AM
Hi,

Any feedback? Its currently a blocking issue at customer site...

Kind regards,

Mike
0
Vlad
Telerik team
answered on 10 Jan 2012, 08:33 AM
Hello,

 According to your private ticket info you are using old version of RadGridView (2010.3 1314) - Q3 2009 Sp1. Can you confirm this? As far as I remember we had such issue before however it was fixed back in 2010. Can you check your scenario with our latest official version?  

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mike
Top achievements
Rank 1
answered on 10 Jan 2012, 09:44 AM
Hi Vlad,

Sorry about the confusing, the version being used (I just doublechecked) is 2010.2.0716.35.

We cannot test a newer version of Telerik, because version 2010.2.0716.35 is being used in the application and the code will break when using a newer version of Telerik because of changed interfaces.

Kind regards,
Mike overmeijer
0
Mike
Top achievements
Rank 1
answered on 10 Jan 2012, 11:03 AM
Hi Vlad,

We have another screen which is simular, but this screen has not the same issue, but its also using a GridView with a column defined in the UserControl.Resources.. I dont understand why one screen works and the other doesnot work.

<UserControl x:Class="BrabantWater.UI.Screens.ZPrioritairListScreen"
    xmlns:Common="clr-namespace:Sap.Eam.UI.UIControl.Common"
    xmlns:imageFactory="clr-namespace:Sap.Eam.UI.Theme;assembly=CustomTheme_WPF"
    Height="auto" Width="auto">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibility" />
        <DataTemplate x:Key="StatusButtons">
            <StackPanel Orientation="Horizontal" Width="110">
                <telerik:RadButton Click="RadButtonOk_Click"
                                   IsEnabled="{Binding Path=IsEditable, Mode=OneWay}"
                                   Width="50">
                    <Image Source="{Binding Path=OkImage, Mode=OneWay}" Width="32"/>
                </telerik:RadButton>
                <telerik:RadButton Click="RadButtonNok_Click"
                                   IsEnabled="{Binding Path=IsEditable, Mode=OneWay}"
                                   Width="50">
                    <Image Source="{Binding Path=NokImage, Mode=OneWay}" Width="32"/>
                </telerik:RadButton>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="GroupHeader">
            <Grid Height="50" VerticalAlignment="Center">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="288" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <TextBlock VerticalAlignment="Center" Text="{Binding Group.Key, Mode=OneWay}" />
                <telerik:RadButton Click="RadButtonGroup_Click" Tag="{Binding Group.Key, Mode=OneWay}"
                                   IsEnabled="{Binding Path=IsEditable, Mode=OneWay}"  Height="40" Width="50" Grid.Column="1">
                    <Image Source="pack://application:,,,/CustomTheme_WPF;component/Common/Images/ok48.png"/>
                 </telerik:RadButton>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
     
    <Grid x:Name="GridContainer">
        <telerik:RadGridView x:Name="PrioritairGrid"
                             AutoExpandGroups="True"
                             AutoGenerateColumns="false"
                             ColumnWidth="*"
                             EditTriggers="None"
                             CanUserFreezeColumns="False"
                             GroupHeaderTemplate="{StaticResource GroupHeader}"
                             HorizontalContentAlignment="Stretch"
                             MouseDoubleClick="PrioritairGrid_MouseDoubleClick"
                             RowIndicatorVisibility="Collapsed"  
                             SelectedItem="{Binding Path=CurrentPrioritair, Mode=TwoWay}"
                             SelectionChanged="PrioritairGrid_SelectionChanged"
                             ShowColumnHeaders="False" 
                             ShowGroupPanel="false"
                             >
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=ItemCode, Mode=OneWay}"  IsVisible="False" IsGroupable="True"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=ItemCodeDescription, Mode=OneWay}" IsGroupable="True" IsVisible="False" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=DamageCodeDescription, Mode=OneWay}" IsGroupable="False" MinWidth="250" />
                <telerik:GridViewColumn CellTemplate="{StaticResource StatusButtons}" MaxWidth="125"/>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=TaskCodeDescription, Mode=OneWay}" IsGroupable="False" MinWidth="100" />
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=ActivityCodeDescription, Mode=OneWay}" IsGroupable="False" MinWidth="100" />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</UserControl>
0
Vera
Telerik team
answered on 11 Jan 2012, 11:13 AM
Hello,

We were able to reproduce the described issue with version 2010.2.716.35. Actually, our Q2 SP1 2010 (2010.2.812.35) version includes the fix and we would suggest you to upgrade to it. I have attached a project with updated binaries so you can test it on your side.

Greetings,
Vera
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Martin
Top achievements
Rank 1
answered on 11 Jan 2012, 03:33 PM
Hi Vera,

Issue is solved with this version, thanks for the feedback!

Kind regards,
Mike
Tags
GridView
Asked by
Mike
Top achievements
Rank 1
Answers by
Mike
Top achievements
Rank 1
Vlad
Telerik team
Vera
Telerik team
Martin
Top achievements
Rank 1
Share this question
or