I tried another approach to get it smaller and this approach has same output but has size of 2,402 Bytes instead of 2,449 with earlier approach so it wins by 47 bytes 🙂
- I created a new project in VS (Chose “Generate HTML Test Page to host Silverlight…” option)
- Deleted following files
- AssemblyInfo.cs from Properties
- Only references I kept were (mscolib, System and System.Windows)
- Deleted Page.xaml (& Page.xaml.cs)
- Also marked App.xaml to be of type Resource rather than silverlight page so that partial class generation does not happen.
<Application xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SilverlightApplication4.App" > <Application.RootVisual> <Canvas> <TextBlock Text="Hello Silverlight"/> </Canvas> </Application.RootVisual> </Application>
Manifest looks exactly the same.
you can not get rid of the partial class all together. Since app class is like a main for silverlight application, only things activation code knows is the application class to be instantiated. This class is supposed to find the xaml (in this case, XAML also defines what goes in Visual root).
here is the sample project.