XAML: Accessing arbitrary objects in Application's ResourceDictionary?

Initialized in the overridden OnStartup method but available in an Startup event handler.

Up vote 0 down vote favorite 1 share g+ share fb share tw.

Being a XAML/WPF newbie, I tried to put an arbitrary (i.e. Non-WPF) object into my applications resources like and access it from my code-behind file using public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base. OnStartup(e); var obj = (MyClass)this.

FindResource("Model"); obj.DoSomething(); } } FindResource got me a ResourceReferenceKeyNotFoundException. I'd be very grateful if someone could tell me what I'm doing wrong! Wpf xaml codebehind resourcedictionary link|improve this question asked Mar 14 '11 at 10:24MartinStettner8,7001038 53% accept rate.

– devdigital Mar 14 '11 at 10:55 Your code as it is works fine on my machine. Make sure you're not mispelling the resource name in your actual code – Jean-Louis Mar 14 '11 at 11:13 It seems that overriding OnStartup is not the same as binding to the Startup event. See my response below... – MartinStettner Mar 14 '11 at 11:30.

Initialized in the overridden OnStartup method but available in an Startup event handler. When I use the Startup event instead of overriding OnStartup like: and private void Application_Startup(object sender, StartupEventArgs e) { everything worked fine!

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.

Related Questions