What is the order: SilverlightPlugin.OnPluginLoaded, App.Application_Startup and Page.Page_Loaded and MyCustomControl.OnApplyTemplate
Tuesday, March 18, 2008 12:35 PM
Here is the setup.
The effect is NullReferenceException. That is because inside the control RootElement was not yet instantiated. That is because MyCustomControl.OnApplyTemplate has not yet been called. it is inside OnApplyTemplate I instantiate ElementRoot
ElementRoot = GetTemplateChild(ElementRootName)as FrameworkElement;
The long question - what is the inner mechanics? I assumed without actually knowing, that plugin loads, it downloads the XAP, creates teh App, hence App.App() is called, then it somehow calls Application_Startup and Page() gets created, where its Loaded event is routed to Page_Loaded handler
InitializeComponent();this.Loaded += new RoutedEventHandler(Page_Loaded);