Sowvik Roy
Sowvik Roy

Reputation: 913

How to add recently open documents to the OpenRecent menu items in WPF

I had develop an Wpf application which open an .doc file and doing some operations. Now I want to add open recent feature in menu items which shows the list of recently opened document. Now there is a wpf class called jump list but I do not understand how to use the jump list in my application.

Upvotes: 2

Views: 2340

Answers (1)

Adrian Fâciu
Adrian Fâciu

Reputation: 12572

You can use the ShowRecentCategory property of the JumpList. When you start the app create the jump list:

JumpList jumpList = new JumpList();
jumpList.ShowRecentCategory = true;
JumpList.SetJumpList(Application.Current, jumpList);

Then when you want to add a document to the recent list use the AddToRecentCategory method:

JumpList.AddToRecentCategory(/*item path*/);

Important to rememer: "If your application is not registered to handle the file type of the item, it will not appear in the Recent list and calls to AddToRecentCategory(String) will fail silently."

Upvotes: 4

Related Questions