tags:

views:

557

answers:

3

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.

+3  A: 

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

Phill Duffy
I am working on wpf application. in that there is no application.config. How to do that in c#.
Check out Scott Hanselmans Baby Smash example, he uses the Configurationhttp://www.hanselman.com/blog/LearningWPFWithBabySmashConfigurationWithDataBinding.aspx
Phill Duffy
Thanks for ur reply
No app.config is created by default, but you can add it yourself... Just go to the Settings tab of the project properties, it will prompt you to create a settings file.
Thomas Levesque
Thanks for ur reply. I opened settings tab of project properties. It asks to create a setting file. But i dont know how to create setting file to save the treeview selected items after closing the application.. Any Help plz
+3  A: 

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.

Adam V
+1  A: 

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.

Ramesh Soni
Where i can get application settings in wpf application. any source code please..thanks
Hi i want to know how to set selectedvaluepath for treeview. can u plz post that source code if u have with u