You can't use the Source property to load a Resource Dictionary from code.
Up vote 2 down vote favorite share g+ share fb share tw.
I'm trying merging wpf resource dictionaries on the code behind but for some reasion this isn't working. If I try merge the dictionaries on the document itself it's running for instance: This is working, but if I comment the ResourceDictionary. MergedDictionaries and in code try this: ResourceDictionary skin = new ResourceDictionary(); skin.
Source = styleLocation; ResourceDictionary skinFather = new ResourceDictionary(); skinFather. MergedDictionaries. Add(skin); skinFather.
Source = styleLocationFather; This will break because can't find the resource. C# wpf styles resourcedictionary link|improve this question edited Aug 15 '11 at 16:52Dave Clemmer1,77331030 asked Apr 12 '10 at 13:38João Loureiro112.
You can't use the Source property to load a Resource Dictionary from code. From MSDN: "Merged dictionaries can be added to a Resources dictionary through code. The default, initially empty ResourceDictionary that exists for any Resources property also has a default, initially empty MergedDictionaries collection property.
To add a merged dictionary through code, you obtain a reference to the desired primary ResourceDictionary, get its MergedDictionaries property value, and call Add on the generic Collection that is contained in MergedDictionaries. The object you add must be a new ResourceDictionary. In code, you do not set the Source property.
Instead, you must obtain a ResourceDictionary object by either creating one or loading one. One way to load an existing ResourceDictionary to call XamlReader. Load on an existing XAML file stream that has a ResourceDictionary root, then casting the XamlReader.
Load return value to ResourceDictionary. " Hence, some pseudo code: ResourceDictionary myResourceDictionary = XamlReader. Load(someXamlStreamReader); anotherResourceDictionary.
MergedDictionaries. Add(myResourceDictionary); Here is another example of how to do it: Uri uri = new Uri("/PageResourceFile. Xaml", UriKind.
Relative); StreamResourceInfo info = Application. GetResourceStream(uri); System.Windows.Markup. XamlReader reader = new System.Windows.Markup.XamlReader(); Page page = (Page)reader.
LoadAsync(info. Stream).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.