New Treeviewitem - Fails on BeginEdit

2 posts, 0 answers
  1. Paul Gallen
    Paul Gallen avatar
    156 posts
    Member since:
    Jun 2008

    Posted 20 May 2009 Link to this post

    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
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 25 May 2009 Link to this post

    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.
Back to Top