Reputation: 12832
In my 3d application, I have a TreeView
that is databound to an ObservableCollection
of objects in my 3d scene. In theory a user can click on an object in the 3d view, which should update the TreeView
to select the corresponding item. But I don't exactly know how. All I have is the 3d object the user picked.
How do I go about doing this?
Upvotes: 1
Views: 2547
Reputation: 12832
Found the solution right here.
http://blog.quantumbitdesigns.com/2008/07/22/programmatically-selecting-an-item-in-a-treeview/
And he's got sample source code that works, which kicks all kinds of ass.
Upvotes: 4
Reputation: 7172
I would assume both the treeview and scene item would share ( and be identified by ) a common ID value. Then, in either your 3D scene or Treeview, implement and subscribe to an OnSelectionChanged, which your TreeView probably already has. Then, when one is updated/changed, the other should be notified instantly, and update itself accordingly. Be sure of course to eat the change even on the update or you will create a nasty loop of OnChange events.
... or, did I misunderstand your question?
Upvotes: -2