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