This project is read-only.

How to create a View using XAML

The following steps are a rough guideline to using a view that has been declared using XAML.
1. Add an XML file to your projects (preferrably in a Views folder) to match the name of your view, e.g. Welcome.xml.
2. Set the properties on the XML file to be an Embedded Resource.
3. Add whatever XAML you like - the following represents a very minimal View.
<?xml version="1.0" encoding="utf-8" ?>
<View xmlns="" xmlns:x="" DesiredSize="Unbound">
  <TextElement DesiredSize="Unbound" 
                       Foreground="200,200,200" Text="Animation Demo" Angle="315" AutoSize="True" 
                       HorizontalAlignment="Center" VerticalAlignment="Center"/>
4. Render the XAML into a View using the supplied Spencen.Mobile.UI.Markup.XamlRenderer.
var text = (System.IO.Stream) System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( "Demo.Views.WelcomeView.xml" );
var xamlRenderer = new XamlRenderer( Canvas1, this );
var view = (View)xamlRenderer.Render( text );
5. Assign the created View to the View property of the Canvas control - either directly or via the TransitionNavigator.
Canvas1.View = view;

Last edited Nov 9, 2009 at 12:38 PM by spencen, version 1


No comments yet.