views:

257

answers:

1

I'm working with the July '09 CTP of the .Net RIA services, and binding an object of Group=>Department=>Category objects to a treeview, and then having a hierarchialdatatemplate render each of the three object types.

What my end goal is for this will be to enable drag-n-drop functionality so that I can quickly edit my list of groups=>departments=>categories, and change their respective relationships in a more intuitive manner than what was previously available.

My current issue is that when I do the drop command, and submit the changes that need to be submitted to the data context, my treeview is redrawing, and collapsing the leaves. Is there a method by which I can use to avoid the collapse?

A: 

I've not done a lot of Silverlight work, but from what I've seen it has a pretty limited object model, so some of the events/properties/methods to do this may not be there. But you could try saving/restoring the state yourself... something akin to the following pseudo-code:

private expandeds as collection();

tree.OnNodeExpand() {
    expandeds.add(tree.CurrentNode.key);
}

tree.OnNodeCollapse() {
    expandeds.remove(tree.CurrentNode.key);
}

tree.AfterBind() {
    for each key in expandeds {
        tree.FindNodeByKey(key).expanded = true;
    }
}
eidylon