Search code examples
c#silverlightboo

Minimal Silverlight example


What is the really minimal example of Silverlight application?

For example, I made the following example with IronPython:

from System.Windows import Application
from System.Windows.Controls import Canvas, TextBlock

canvas = Canvas()
textblock = TextBlock()
textblock.FontSize = 24
textblock.Text = 'Hello!'
canvas.Children.Add(textblock)

Application.Current.RootVisual = canvas

Then I used chiron and it created a .xap file. No (explicit) XAML, no nothing. Is it possible to do the same in, say, C#? One source file which I could compile from command line? If so, what would the source code be?

My motivation is to try and create silverlight app with unconventional languages, right now I am stuck at Boo...


Solution

  • using System;
    using System.Windows;
    using System.Windows.Controls;
    
    namespace MimimalSilverlightApp
    {
        public class App : Application
        {
            public App()
            {
                this.Startup += this.Application_Startup;
            }
    
            private void Application_Startup(object sender, StartupEventArgs e)
            {
                var canvas = new Canvas();
    
                var textblock = new TextBlock();
                textblock.FontSize = 24;
                textblock.Text = "Hello!";
                canvas.Children.Add(textblock);
    
                this.RootVisual = canvas;
            }
        }
    }