If the ResourceDictionary
is loaded in your context you can do the following to load a resource:
var buttonBrush = (Brush)FindResource("Button01");
Otherwise you have to first load the ResourceDictionary
:
ResourceDictionary loadedDictionary;
using (FileStream fs = new FileStream("yourpath/Skin.xaml", FileMode.Open))
{
loadedDictionary = (ResourceDictionary)XamlReader.Load(fs);
}
var buttonBrush = (Brush)loadedDictionary["Button01"];
Edit: With a foreach loop you could get key and value of the dictionary entry:
foreach (DictionaryEntry entry in loadedDictionary)
{
var key = entry.Key;
var resource = entry.Value;
}