Tracking source node on WCF call

2 posts, 0 answers
  1. Tony
    Tony avatar
    5 posts
    Member since:
    Apr 2008

    Posted 27 Jan 2009 Link to this post

    I'm sure I'm overlooking something simple, but here is the problem I face:

    I have a LoadOnDemand TreeView that calls a WCF service to pull the data.  Originally, I stored a private RadTreeViewItem property in the calling control (currentItem), so when the WCF returned, I could add the children to currentItem node.

    This method worked fine until we tested against a production data source, which could take approximately 5 seconds to return the requested data.  If the user selected a different node to expand during this time, my pointer reference would be messed up.  Effectively adding the nodes for Node A to Node B.

    So now the question, what is the best practice to insure the WCF return is dealing with the original TreeViewItem?  I attempted to just send the RadTreeViewItem across as an object, but it will not serialized.

    Another note:  My next thought was to send the FullPath of the node to WCF and return it with the results.  My question is, what if there are nodes with the same Header value.  Will they return the same path?

    Any thoughts/suggestions would be greatly appreciated.

  2. hwsoderlund
    hwsoderlund avatar
    419 posts
    Member since:
    Aug 2006

    Posted 29 Jan 2009 Link to this post

    Do you have a unique identifier on the data objects that the treeview is bound against? If not, maybe you could create one. Then you could use that value to send to WCF and then back again, instead of sending the RadTreeViewItem or the full node path. By the way, you can use the auto-generated "userState" parameter to have something sent back and forth across the wire automatically, you don't have to code for it yourself. Of course that only applies if you use "Add service reference" to generate your proxy.

    If you don't have a unique id I would suggest that you generate a GUID, slap that value in the Tag property of the RadTreeViewItem, send the same guid to wcf and then when you get it back in the userState parameter, just find the node and populate the children.

    Yet another solution is to make your service call inline, like so (pseudo code):

    //The clicked node 
    RadTreeViewItem clickedNode = new RadTreeViewItem(); 
    var MyClient = new ApplicationServices().GLSClient; 
    MyClient.GetNodesCompleted += delegate(object sender, GetNodesCompletedEventArgs e) 
        //The same node will be available on callback 
        clickedNode.ItemsSource = e.Result; 

  3. DevCraft banner
Back to Top