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

NullReferance Exception after click on RadTreeViewItem

1 Answer 46 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Oded Zadok
Top achievements
Rank 1
Oded Zadok asked on 16 Feb 2010, 10:53 AM
hi,

i get this exception: "System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Controls.RadTreeViewItem.OnHeaderMouseLeftButtonDown(Object sender, MouseButtonEventArgs e)
after selecting (by mouse) node on the tree.

Remark : i don't get the exception if i used the keyboard for change selected node (item)

this is my XAML deceleration

<Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <view:CheckBoxConverter x:Key="checkBoxConverter" />
            
            <telerikControls:ContainerBindingCollection x:Name="BindingsCollection">
                <telerikControls:ContainerBinding PropertyName="CheckState" Binding="{Binding IsChecked, Converter={StaticResource checkBoxConverter}}"/>
                <!--<telerikControls:ContainerBinding PropertyName="Header" Binding="{Binding Name}"/>-->
                <telerikControls:ContainerBinding PropertyName="DefaultImageSrc" Binding="{Binding IconName}"/>
                
                <!--Other Container Bindings-->
            </telerikControls:ContainerBindingCollection>

            <telerikControls:HierarchicalDataTemplate x:Key="AlienTemplate" ItemsSource="{Binding SubLayers}" telerikControls:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}">
                <telerikNavigation:RadTreeViewItem IsEditable="False" Header="{Binding Name}" >
                        </telerikNavigation:RadTreeViewItem>
            </telerikControls:HierarchicalDataTemplate>
        </Grid.Resources>

        <Border Background="#995C90B2" BorderThickness="1" CornerRadius="5"
                HorizontalAlignment="Right"  VerticalAlignment="Top"
                Margin="20" Padding="10" BorderBrush="Black" >
            <StackPanel VerticalAlignment="Stretch">
                <TextBlock Text="Layers in map service" FontWeight="Bold" />

                <Grid ScrollViewer.VerticalScrollBarVisibility="Auto"  >
                    <telerikNavigation:RadTreeView SelectionMode="Single" IsLineEnabled="True" 
ItemsOptionListType="CheckList"
IsOptionElementsEnabled="True" 
IsRootLinesEnabled="True"
                     x:Name="RadTreeView" IsTriStateMode="True" ItemTemplate="{StaticResource AlienTemplate}" >
                        
                    </telerikNavigation:RadTreeView>
                </Grid>
            </StackPanel>
        </Border>

    </Grid>

BTW - I'm using RadControls_for_Silverlight_2009_3_1314 with SL 4

Thanks.
Oded

1 Answer, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 16 Feb 2010, 01:54 PM
Hello Oded,

The problem is caused by the fact that you have placed a RadTreeViewItem in the HierarchicalDataTemplate("AlienTemplate"). One possible correct version of the HierarchicalDataTemplate might be:

<telerikControls:HierarchicalDataTemplate
    x:Key="AlienTemplate"
    ItemsSource="{Binding SubLayers}" 
    telerikControls:ContainerBinding.ContainerBindings="{StaticResource BindingsCollection}">
    <ContentPresenter Content="{Binding Name}" />
</telerikControls:HierarchicalDataTemplate>

Give this approach a try and let me know if you encounter additional problems.

All the best,
Kiril Stanoev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
TreeView
Asked by
Oded Zadok
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Share this question
or