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

New Treeviewitem - Fails on BeginEdit

1 Answer 26 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Paul Gallen
Top achievements
Rank 1
Paul Gallen asked on 20 May 2009, 04:47 PM
Hi

given the code below is there any reason why my NewNode.Begin edit is causing an exception - object ref not set to an instance of an object. This works fine if I omit the BeginEdit

  Dim NewNode As New RadTreeViewItem  
 
        NewNode.Header = Now  
 
        Me.CurrentTreeViewItem.IsExpanded = True 
        Me.CurrentTreeViewItem.Items.Add(NewNode)  
 
        NewNode.IsSelected = True 
 
        NewNode.BringIntoView()  
        NewNode.BeginEdit() 
 
Thanks

P

1 Answer, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 25 May 2009, 06:41 AM
Hi Paul Gallen,

The problem with this code is that the new item is still not generated, because of the asynchronous nature of the Silverlight layout system.

To resolve this, you need to call the BeginEdit method with Dispatcher.Invoke:
http://msdn.microsoft.com/en-us/library/cc190259(VS.95).aspx

Dispatcher.BeginInvoke(AddressOf EditNode)  
 


Private Sub EditNode()  
    NewNode.BeginEdit()
End Sub 

Please let us know if you have any problems with this approach.

Best wishes,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
Paul Gallen
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Share this question
or