I 开发者_如何学Cam creating an MRU, Most Recent Used, class for my WPF application. I have the main class working and it manages the list of recent files.
My issue is displaying the list of files inline. All of the examples that I can find display the list in a submenu, where you can the MRU helper class the sub menu item and it can add, remove and clear the list of recent files. I want to have this list on my main File menu. I know I once saw an example, which I can no longer find, that had you derive your MRU class from Separator. You included this class on your File menu. If no recent files exist it would just display a separator. If you had a list it would display the separator, the list of files and another separator.
I don't want my MRU helper class to have any knowledge or reference to my File menu. I want to be able to somehow have a placeholder in my File menu that my MRU helper class will have knowledge of and be able to create whatever items it needs.
I was also planning on storing my MRU list in Properties.Settings.Default rather than the registry. I notice most examples use the registry. Am I wrong to do it this way?
Check out This CodeProject article.
There is nothing wrong with storing the list in Properties.Settings
. You can create a StringCollection
entry for the list. IMO it is better than registry which you don't know whether the user has access. Also see this answer.
精彩评论