Xamarin Goes Dual Screen

David Ortinau

Surface Duo introduces a whole new class of ultra-portable experiences running on dual screens. Today we are excited to announce our public preview of the SDK for Surface Duo. Xamarin developers can take advantage of the new SDK to enlighten existing apps and create innovative experiences that inspires creativity.

Surface Duo Dual Screen Iphone and Ipad

Get Creative with Dual Screen

As you look at your current app screens and features, consider the following user experience patterns that might be best suited. By default, your app will run on the left or top screen depending on the orientation of the device. You then want to consider if your app should remain like that or if you could adopt one of these recommended patterns:

  • Extended Canvas
  • Master-Detail
  • Two Page
  • Dual View
  • Companion View

Recommended Patterns for Duel Screen Apps
The SDK for Surface Duo will help you avoid misaligning things behind the hinge. There are other things you will want to be mindful of when building for dual-screen experiences, and we’ve covered many of those for you here in our documentation.


Get Started

Ready to take the Duo for a spin and start creating powerful new app experiences? Download the SDK for Surface Duo and Android emulator today, and then hop over to our array of Xamarin samples on GitHub. The most useful APIs to use today are provided from the ScreenHelper class which will return a Boolean indicating if the device is a Duo.

protected override void OnCreate(Bundle savedInstanceState)
    screenHelper = new ScreenHelper();
    isDuo = screenHelper.Initialize(this);

You can also access other helpful features such as rotation, isDualMode, and hinge angle. Check the samples for more info.

Take advantage of this today in Xamarin.Forms with a custom layout. This works in any version of Xamarin.Forms, no updates needed. For this initial launch we’ve created a custom layout dubbed the TwoPaneView that manages both screens, positions content, avoids the hinge area, and reacts to rotation. You can set the behavior of your layout with a simple enum:

public enum DuoSplitPaneBehavior

The following custom layout takes two children, one for each pane (or screen). This example shows the companion pane pattern using a TwoPaneView  custom layout.


    <local:TwoPaneView x:Name="twoPaneView">
        <CarouselView x:Name="cv" BackgroundColor="LightGray" PositionChanged="OnCarouselViewPositionChanged" 
                      HeightRequest="{Binding Source={x:Reference mainPage}, Path=FormsWindow.Pane1.Height}">
                    <Frame BackgroundColor="LightGray" Padding="0" Margin="0" 
                           WidthRequest="{Binding Source={x:Reference mainPage}, Path=FormsWindow.Pane1.Width}"
                           HeightRequest="{Binding Source={x:Reference mainPage}, Path=FormsWindow.Pane1.Height}">
                        <Frame Margin="20" BackgroundColor="White">
                            <Label FontSize="Large" Text="{Binding ., StringFormat='Slide Content {0}'}" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" HorizontalOptions="Center" VerticalOptions="Center"></Label>
        <CollectionView x:Name="indicators" 
            Margin="20, 20, 20, 20"
            ItemsSource="{Binding Source={x:Reference cv}, Path=ItemsSource}">
                    <Style TargetType="Frame">
                        <Setter Property="VisualStateManager.VisualStateGroups">
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="Selected">
                                            <Setter Property="BorderColor" Value="Green" />
                <LinearItemsLayout Orientation="Vertical" ItemSpacing="10"></LinearItemsLayout>
                    <Frame CornerRadius="10" HeightRequest="100" BackgroundColor="White" Margin="0" Padding="1">
                        <StackLayout HorizontalOptions="Fill" VerticalOptions="Fill"  Orientation="Horizontal">
                            <Label FontSize="8" Padding="20,0,20,0" VerticalTextAlignment="Center" WidthRequest="100" Text="{Binding ., StringFormat='Slide Content {0}'}"></Label>
                            <Label FontSize="Micro" Padding="20,0,20,0" VerticalTextAlignment="Center" HorizontalOptions="FillAndExpand" BackgroundColor="DarkGray"  Grid.Column="1" Text="{Binding ., StringFormat='Slide {0}'}"></Label>

Dual Screen Sample gif
We have a sample showing an array of different layouts supporting all of the pattern guidance mention in our documentation. Start exploring here.


Get Dreaming About Dual Screen

Surface Duo is the first in this whole new class of devices and app experiences. When Surface Neo is available running Windows 10X, we’ll share continued support for that experience with first-class support in Xamarin.Forms. The amazing news is that all the work you see here to support dual-screen experiences for the Surface Duo are 100% cross-platform and required no changes to Xamarin.Forms itself.

What do you dream of doing with these new devices? What interesting types of UI does this inspire you to build?

We’d love to hear from you! Help guide our investment in supporting your vision and schedule a call with us to discuss.

Additional Resources:


Bonus: Live Stream Today!

Today at 12:30 PST we will be live streaming on Twitch with David Ortinau, Jonathan Dick, and Shane Neuville walking you through setting up the SDK and exploring the samples. Join us on Twitch!