Rob Relyea received a customer request for
how a XAML downloaded from a server can still have events and decided to discuss the options for .NET 3.x, 4 and Silverlight.
By default, when you add a XAML page into a project in VS or Blend, its BuildAction (shown in the properties pane – F4) is Page. When you build the assembly, MarkupCompilePass1 and MarkupCompilePass2 will analyze all the Pages and generate generated code files (.g.cs, .g.vb, etc…) and .baml files. When you navigate to the url of the XAML or do a new of the class defined in the XAML, it will end up calling Application.LoadComponent, which will load the class and the baml file.