Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Dual-screen devices like the Microsoft Surface Duo facilitate new user-experience possibilities for your applications. Xamarin.Forms includes TwoPaneView and DualScreenInfo classes so you can develop apps for dual-screen devices.
Get started
Follow these steps to add dual-screen capabilities to a Xamarin.Forms app:
Open the NuGet Package Manager dialog for your solution.
Under the Browse tab, search for
Xamarin.Forms.DualScreen.Install the
Xamarin.Forms.DualScreenpackage to your solution.Add the following initialization method call to the Android project's
MainActivityclass, in theOnCreateevent:Xamarin.Forms.DualScreen.DualScreenService.Init(this);This method is required for the app to be able to detect changes in the app's state, such as being spanned across two screens.
Update the
Activityattribute on the Android project'sMainActivityclass, so that it includes all theseConfigurationChangesoptions:ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.UiModeThese values are required so that configuration changes and span state can be more reliably reported. By default only two are added to Xamarin.Forms projects, so remember to add the rest for reliable dual-screen support.
Troubleshooting
If the DualScreenInfo class or TwoPaneView layout aren't working as expected, double-check the set-up instructions on this page. Omitting or misconfiguring the Init method or the ConfigurationChanges attribute values are common causes of errors.
Review the Xamarin.Forms dual-screen samples for additional guidance and reference implementation.
Next steps
Once you've added the NuGet, add dual-screen features to your app with the following guidance:
- Dual-screen design patterns - When considering how to best utilize multiple screens on a dual-screen device, refer to this pattern guidance to find the best fit for your application interface.
- TwoPaneView layout - The Xamarin.Forms
TwoPaneViewclass, inspired by the UWP control of the same name, is a cross-platform layout optimized for dual-screen devices. - DualScreenInfo helper class - The
DualScreenInfoclass enables you to determine which pane your view is on, how big it is, what posture the device is in, the angle of the hinge, and more. - Dual-screen triggers - The
Xamarin.Forms.DualScreennamespace includes two state triggers that trigger aVisualStatechange when the view mode of the attached layout, or window, changes.
Visit the dual-screen developer docs for more information.