Quick Silverlight (and WPF) tip: How to write program without XAML
From the moment, 10K MIX09 contest was launched, I got more, then 20 people, asking the same question: Is it possible to have Silverlight program up and running without XAML at all?
The answer is “YES, IT IS”. Here is how:
All you need for run WPF or Silverlight application is
- Class inherited from System.Windows.Application
- Class inherited from System.Windows.Controls.UserControl
So, Let’s create new WPF or Silverlight application and delete all files from the project directory. Then add one file, named App.cs (or Foo.cs or Whatever.cs – the length of the file name is not included
) and write there :
using System.Windows.Controls;
using System.Windows;public class App : Application {public App() {this.Startup += (s, e) => { this.RootVisual = Foo.M; };}}
class Foo: UserControl {static Foo _b = new Foo();public static Board M { get { return _b; } }
We done. F5, be happy. You just wrote first officially smallest Silverlight functional application. Good luck with Mix09 contest.
You may also be interested with:
December 23rd, 2008 · Comments (3)
3 Responses to “Quick Silverlight (and WPF) tip: How to write program without XAML”
Leave a Reply
Discover other tags
My tools
- .NET Framework Detector
- Duplicate images finder
- Exchange Security Policy for Windows Mobile Devices Fix
- Gas Price Windows Vista SideBar gadget
- Israel Traffic Information Windows Vista SideBar gadget
- Localization fix for SAP ES Explorer for Visual Studio
- LocTester
- RTL and LTR in Windows Live Writer
- Silverlight controls library
- Snipping tool integration plugin for WLW
- USB FM receiver library
- Vista Battery Saver
- WebCam control for WPF
- Windows Live SkyDrive attachment for Windows Live Writer
- Wireless Migrator
- WPF Virtual Keyboard





January 1st, 2009 at 12:59 am
In this issue: Jim Lynn, Silverlight Girl, Microsoft Natal, Damon Payne, Lutz Gerhard, Tamir Khason,
January 1st, 2009 at 1:00 am
You’ve been kicked (a good thing) – Trackback from DotNetKicks.com
November 30th, 2009 at 10:18 am
What reference do you need to have the “Board” variable get resolved?
public static Board M
I am new to WPF and Silverlight, but I just tried to follow your instructions:
Create a new WPF or Silverlight application
Delete all files from the project directory
Add an App.cs with the code supplied
Is Board replaced with UIElement or something?