AboutBlogContact
Web DevelopmentNovember 14, 2008 2 min read 123Updated: June 22, 2026

Silverlight 2: XAML and C# Interop (2008)

AunimedaAunimeda
📋 Table of Contents

Silverlight 2: XAML and C# Interop

Microsoft's "Flash killer" has arrived in its second version. Silverlight 2 isn't just a media player; it's a cross-platform version of the .NET framework that runs in the browser. The separation of concerns between XAML (UI) and C# (Logic) is a breath of fresh air.

Declarative UI with XAML

XAML allows you to define your UI in a clean, XML-based format.

<!-- MainPage.xaml -->
<UserControl x:Class="AunimedaApp.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid x:Name="LayoutRoot" Background="White">
        <Button x:Name="MyButton" Content="Click Me" 
                Click="MyButton_Click" Width="100" Height="30"/>
    </Grid>
</UserControl>

Code-Behind in C#

The logic is handled in a partial class. Because it's the real .NET CLR, you get generics, LINQ, and strong typing.

// MainPage.xaml.cs
namespace AunimedaApp
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void MyButton_Click(object sender, RoutedEventArgs e)
        {
            MyButton.Content = "Processing...";
            // Call a WCF service asynchronously
            FetchData();
        }
    }
}

Deep Zoom and Beyond

Silverlight 2 also brings "Deep Zoom" (MultiScaleImage), which allows for smooth zooming into gigapixel images. By using the .xap file format (which is just a renamed .zip), Silverlight bundles your assemblies and assets into a single package. If you're a .NET developer, the web just became a whole lot more friendly.


Aunimeda develops websites and web applications for businesses - corporate sites, e-commerce, portals, and custom platforms.

Contact us to discuss your web project. See also: Web Development, E-commerce Development

Read Also

Silverlight 1.0: Microsoft's Answer to Flashaunimeda
Web Development

Silverlight 1.0: Microsoft's Answer to Flash

The 'Flash Killer' has arrived. Microsoft Silverlight 1.0 brings the power of .NET and XAML to the browser, promising a richer, more developer-friendly web.

SOAP: The Dream of Universal Web Servicesaunimeda
Web Development

SOAP: The Dream of Universal Web Services

Is the era of proprietary middleware over? SOAP promises to let any application talk to any other application over the standard web, using the power of XML.

Internet Explorer 3.0: Microsoft's First Real Contenderaunimeda
Web Development

Internet Explorer 3.0: Microsoft's First Real Contender

Microsoft has finally caught up. IE 3.0 supports CSS, JScript, and ActiveX, making it a serious threat to Netscape's dominance.

Need IT development for your business?

We build websites, mobile apps and AI solutions. Free consultation.

Web Development

Get Consultation All articles