add programmatically add items from the resource dictionary


I'm just new in wpf and am planning to use a listbox to generate recently opened or closed items. Everytime a file is opened, it gets added permanently added into a resource dictionary of type listbox item.

On the other hand, besides the listbox item is a button to remove the link.

Is this possible?

ResourceDictionary is a IDictionary. You can use the indexer to add/override items.

myResourceDictionary["somekey"] = someObject;

And you can use the Add() and Remove() method.

As for your scenario I would prefer to use an ObservableCollection instead and bind your listbox to it.