XAMLite (pronounced zamel-lite): A XAML-inspired lightweight UI library for Windows-based XNA 4.0 (Refresh) projects.

By "XAML-inspired", we're referring to the collection of user interface controls that can be instantiated via C#, when working with XAML-based technologies like WPF and Silverlight (as opposed to the XML markup side of XAML).

So XAMLite doesn't actually have any XAML markup? Exactly.  What we do have is the exact same object model for things like Label, TextBlock, Image, etc. controls.  So if you're already familiar with the properties and methods available to XAML controls, you'll be right at home working with XAMLite.

Example

Here's a label in (code-only) XAML:

            Label label = new Label();
            label.Content = "Hello";
            label.Foreground = Brushes.Red;
            label.HorizontalAlignment = HorizontalAlignment.Center;
            label.VerticalAlignment = VerticalAlignment.Center;
            label.Visibility = Visibility.Visible;
            this.Add( label );

Here's - almost exactly the same code, for a label in XAMLite.

            XAMLiteLabel label = new XAMLiteLabel( game );
            label.Content = "Hello";
            label.Foreground = Brushes.Red;
            label.HorizontalAlignment = HorizontalAlignment.Center;
            label.VerticalAlignment = VerticalAlignment.Center;
            label.Visibility = Visibility.Visible;
            game.Components.Add( label );

Rationale

The reason for mimicking the XAML object model and layout conventions for user interface controls is that Microsoft has made it clear that XAML is the plan going forward for UI construction (in the past for XAML in WPF/Silverlight, and in the the future, XAML in WinRT).  So developers are either already familiar with XAML-style interface construction, or if not, they should be and there will be future dividends to becoming XAML-savvy.  As we've already seen in Silverlight 5 on Windows phone, XAML can be directly supported within XNA.  I predict this will happen at some point in the future for desktop XNA application development as well.  This is another reason the XAMLite library is being built following XAML conventions - so that transition (from XAMLite to "real" XAML) is as smooth as possible. 

Project Goals

  • Simple: ease-of-use for new developers is the primary goal.  There should be almost no learning curve for developers who have a beginner-level familiarity with XAML. 
  • Lightweight: this is a library that can be used on top of your application, not a framework that you build your application on top of.  XAMLite doesn't need to be used for all of your UI.
  • No Manager:  this might not be possible, but the goal is avoid a centralized XAMLiteManager which takes all controls and is then responsible for rendering them.   The reason for this is that a high-level UI manager may include assumptions that aren't true for a particular application.  Instead, we provide individual standard low-level XNA DrawableGameponents allowing applications to use them however needed.  (Not having a centralized UI manager will likely have performance costs, but we're not optimizing for performance).
  • Targeting Windows applications.

Project Not-Goals

  • High-performance: optimizing for simplicity, not performance.
  • Comprehensive: not trying to mimic more than 1% of all possible XAML functionality
  • XML-style XAML markup.
  • Visual Studio designer support.
  • Not targeting Xbox or Windows Phone applications.

Last edited May 14, 2012 at 1:03 AM by adamkane, version 20