VISUAL STUDIO   Windows Mac

XAML Standard (Preview)

How to get started exploring the XAML Standard Preview in Xamarin.Forms

PDF for offline use
Related Links:

Let us know how you feel about this

Translation Quality


0/250

last updated: 2017-11

Preview

Follow these steps to experiment with XAML Standard in Xamarin.Forms:

  1. Download the preview NuGet package here.
  2. Add the Xamarin.Forms.Alias NuGet package to your Xamarin.Forms PCL, .NET Standard, and platform projects.
  3. Initialize the package with Alias.Init()
  4. Add an xmlns:a reference xmlns:a="clr-namespace:Xamarin.Forms.Alias;assembly=Xamarin.Forms.Alias"
  5. Use the types in XAML - see the Controls reference for more information.
  1. Download the preview NuGet package here.
  2. Add the Xamarin.Forms.Alias NuGet package to your Xamarin.Forms PCL, .NET Standard, and platform projects.
  3. Initialize the package with Alias.Init()
  4. Add an xmlns:a reference xmlns:a="clr-namespace:Xamarin.Forms.Alias;assembly=Xamarin.Forms.Alias"
  5. Use the types in XAML - see the Controls reference for more information.

The following XAML demonstrates some XAML Standard controls being used in a Xamarin.Forms ContentPage:

<?xml version="1.0" encoding="utf-8"?>
<ContentPage 
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    xmlns:a="clr-namespace:Xamarin.Forms.Alias;assembly=Xamarin.Forms.Alias"
    x:Class="XAMLStandardSample.ItemsPage" 
    Title="{Binding Title}" x:Name="BrowseItemsPage">
    <ContentPage.ToolbarItems>
        <ToolbarItem Text="Add" Clicked="AddItem_Clicked" />
    </ContentPage.ToolbarItems>
    <ContentPage.Content>
        <a:StackPanel>
            <ListView x:Name="ItemsListView" ItemsSource="{Binding Items}" VerticalOptions="FillAndExpand" HasUnevenRows="true" RefreshCommand="{Binding LoadItemsCommand}" IsPullToRefreshEnabled="true" IsRefreshing="{Binding IsBusy, Mode=OneWay}" CachingStrategy="RecycleElement" ItemSelected="OnItemSelected">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Padding="10">
                                <a:TextBlock Text="{Binding Text}" LineBreakMode="NoWrap" Style="{DynamicResource ListItemTextStyle}" FontSize="16" />
                                <a:TextBlock Text="{Binding Description}" LineBreakMode="NoWrap" Style="{DynamicResource ListItemDetailTextStyle}" FontSize="13" />
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </a:StackPanel>
    </ContentPage.Content>
</ContentPage>
ℹ️

Note: requiring the xmlns a: prefix on the XAML Standard controls is a limitation of the current preview.

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.