Reputation:
I am developing a WPF application with a treeview. I have Treeview like windows. Now what I want is if select I the treeviewitem, let's say...
+Desktop | +---My Computer | +---C:\ | +---Some Folder.
I selected the foldername called Some Folder in c drive. After that I close the application. When I open the application again the focus again should be on Some Folder in c drive. In other words, I need the same path selected after re-opening the application.
Upvotes: 2
Views: 1390
Reputation: 16077
Save you TreeView "SelectedValuePath
" value in application settings and re-assign its value at the time of load. Of course you have to take care of its validity. The path might not exists at the time of loading.
Upvotes: 1
Reputation: 6356
Slightly OT - be careful with this. If you quit while pointing to a folder on a flash drive or CD, that location may not exist when you restart the application. By adding this requirement to restart in the old location, you also add the requirement to fail gracefully, and to a different location, if the old location doesn't succeed.
Upvotes: 4
Reputation: 2866
You could save the value in Application.config and then check if it has a value in there when you re-open the app and re-select the branch
Upvotes: 3