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

The RadDataBoundListBix throws a NullReferenceException when updating its Source

4 Answers 52 Views
DataBoundListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sergio
Top achievements
Rank 1
Sergio asked on 05 Feb 2015, 02:31 PM
Hello, I'm having a problem with this control. I have to navigate between a few pages that have a DataBoundListBox inside them, I have set the NavigationCacheMode to enabled, and sometimes I navigate between different instances of the same page.
Everything runs fine, but sometimes the app crashes when I navigate BACK from another page.
This is my XAML setup:

<Primitives:RadDataBoundListBox
x:Name="listBox"
ItemsSource="{Binding Source}"
ItemTap="listBox_ItemTap"
Tapped="listBox_Tapped"
ItemTemplate="{StaticResource ListBoxItemTemplate}"
ItemReorderStateChanged="listBox_ItemReorderStateChanged"
Style="{StaticResource AnimatedDataBoundListBox}"/>
 
 
<!--Style for the RadDataBoundListBox-->
<Style TargetType="Primitives:RadDataBoundListBox" x:Key="AnimatedDataBoundListBox">
    <Setter Property="ItemAnimationMode" Value="PlayAll"/>
    <Setter Property="ItemAddedAnimationInterval" Value="0:0:0.05"/>
    <Setter Property="ItemRemovedAnimationInterval" Value="0:0:0.05"/>
    <Setter Property="IsItemReorderEnabled" Value="False"/>
    <Setter Property="ItemAddedAnimation">
       <Setter.Value>
           <telerikCore:RadPlaneProjectionAnimation
                 StartAngleX="90"
         StartAngleY="-50"
                 StartAngleZ="10"
                 Direction="CounterClockwise"
                 Axes="All"
                 EndAngleX="0"
                 EndAngleY="0"
                 EndAngleZ="0">
               <telerikCore:RadPlaneProjectionAnimation.Easing>
                   <CircleEase EasingMode="EaseOut"/>
               </telerikCore:RadPlaneProjectionAnimation.Easing>
           </telerikCore:RadPlaneProjectionAnimation>
        </Setter.Value>
     </Setter>
     <Setter Property="ItemRemovedAnimation">
        <Setter.Value>
           <telerikCore:RadPlaneProjectionAnimation
                StartAngleX="0"
                StartAngleY="0"
                StartAngleZ="0"
                Direction="Clockwise"
                Axes="X"
                EndAngleX="-90"
                Duration="0:0:0.1"/>
        </Setter.Value>
     </Setter>
     <Setter Property="ListHeaderTemplate">
         <Setter.Value>
            <DataTemplate>
                <Grid Height="55"/>
            </DataTemplate>
         </Setter.Value>
     </Setter>
</Style>
 
<!--Item template-->
<DataTemplate x:Key="ListBoxItemTemplate">
    <ContentControl Holding="ContentControl_Holding">
        <Grid>
            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="0.2*"/>
               <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid Margin="10,10,0,10"
                  MinHeight="55"
                  MinWidth="55"
                  VerticalAlignment="Center">
                <Canvas Background="{StaticResource PhoneAccentBrush}"/>
                <Image Source="{Binding IconImage}"
                       Margin="7"/>
             </Grid>
             <StackPanel Grid.Column="1"
                         Margin="15,0,0,0">
                 <TextBlock Text="{Binding Name}"
                            VerticalAlignment="Center"
                            Foreground="White"
                            FontSize="25"
                            FontWeight="SemiLight"/>
                 <TextBlock
            Text="{Binding FolderContent, Converter={StaticResource FolderConverter}}"
                            VerticalAlignment="Center"
                            Foreground="#FFA0A0A0"
                            FontSize="16"
                            FontWeight="SemiLight"/>
                 <TextBlock Text="{Binding GroupName}"
           Visibility="{Binding GroupName, Converter={StaticResource StringToVisibility}}"
                            Foreground="#707070"
                            FontSize="16"/>
             </StackPanel>
       </Grid>
    </ContentControl>
</DataTemplate>

The Source gets updated inside the OnNavigatedTo event: I create a new ObservableCollection and assign it to the previous Source in my ViewModel.

This is the StackTrace:

Exception: Object reference not set to an instance of an object.
 
StackTrace:   
at Telerik.UI.Xaml.Controls.Primitives.RadVirtualizingDataControl.OnItemRemovedAnimationEnded(RadAnimation animation, SingleItemAnimationContext context)
at Telerik.UI.Xaml.Controls.Primitives.RadDataBoundListBox.OnItemRemovedAnimationEnded(RadAnimation animation, SingleItemAnimationContext context)
at Telerik.UI.Xaml.Controls.Primitives.RadVirtualizingDataControl.OnItemRemovedAnimation_Ended(Object sender, AnimationEndedEventArgs e)
at System.EventHandler`1.Invoke(Object sender, TEventArgs e)
at Telerik.Core.RadAnimation.OnEnded(PlayAnimationInfo info)
at Telerik.Core.RadAnimation.OnStopped(PlayAnimationInfo info)
at Telerik.Core.RadAnimationManager.StopStoryboard(PlayAnimationInfo info)
at Telerik.Core.RadAnimationManager.OnStoryboardCompleted(Object sender, Object e)

Since I don't see anything related to my code over there I'm not sure the crash depends on my methods, do you know why does that happen?

I noticed that this only seems to happen when navigating back.

Thank you for your help!
Sergio

4 Answers, 1 is accepted

Sort by
0
Vladislav
Telerik team
answered on 10 Feb 2015, 09:26 AM
Hi Sergio,

Based only on the provided XAML snippet and description we wasn't able to reproduce the described problem. Is it possible to send us your project (or just the relevant part of it) in order to further investigate it locally? We are particularly interested in setting/resetting the Source in the ViewModel and in the navigating "Back" code.

Thank you in advance.

Regards,
Vladislav
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sergio
Top achievements
Rank 1
answered on 10 Feb 2015, 09:04 PM
Hello, thank you for your answer.
I understand that trying to figure that out using just the code I posted is impossible, and yes I can send you the project (I don't think I'd be able to just share a part of it since there are many different classes that are involved in the various pages I navigate).

The problem is that I'm working on an app that I plan to release on the Store as a paid app, so I can't share my source code here on the forum. If you want you can contact me via email and I can help you with that, I can send you a copy of the project (I just need to be sure that it'll be used for your internal testing only and that it won't be shared elsewhere) and explain the steps needed to recreate the crash.
Let me know if you're interested :)
0
Vladislav
Telerik team
answered on 12 Feb 2015, 08:59 AM
Hello Sergio,

In order to investigate your project you can submit a support ticket to us by following this.
All information (including source code and real projects) exchanged there are strictly confidential and private as is described in the "End User License Agreement" (EULA) for our controls.

Please, feel free to open such ticket and provide us with the information necessary in order to further investigate the original issue.
Thank you for your cooperation.

Regards,
Vladislav
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sergio
Top achievements
Rank 1
answered on 12 Feb 2015, 04:34 PM
Great, I'll send everything there then :)
I also discovered a couple of other things: the Exception gets thrown when navigating forward as well, and I noticed that if I update the Source inside the NavigationHelper_LoadState method instead of OnNavigatedTo, the crash happens less often.
I mean, the app still crashes due to that Exception, but you have to navigate back and forth multiple times to get that error.

I'll include everything inside my report, I hope that helps!
(I really hope so, since a couple of section of my apps are almost unusable due to this problem ahahahahah)

Cheers!
Sergio
Tags
DataBoundListBox
Asked by
Sergio
Top achievements
Rank 1
Answers by
Vladislav
Telerik team
Sergio
Top achievements
Rank 1
Share this question
or