Skip to content

Weather demo showing Xamarin.Forms embedded in Xamarin.iOS, Xamarin.Android, and UWP non-Xamarin.Forms applications.

Notifications You must be signed in to change notification settings

davidortinau/build2017-new-in-xamarin-forms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Microsoft Build 2017 - Weather Sample - Xamarin.Forms Embedding (PREVIEW)

This sample shows a shared Xamarin.Forms UI being embedded into non-Xamarin.Forms iOS, Android and UWP applications. With this method developers can use as much or as little Xamarin.Forms in their application as desired.

The HistoryPage.xaml demonstrates using an image and custom fonts across native applications.

Xamarin.Forms services such as DependencyService and MessagingCenter work with the exception of Navigation. Binding also works when setting the context.

NOTE: This is an early preview and not all features have been evaluated.

Get the 3.0-preview NuGet

This is very early and not merged into Xamarin.Forms master. To get the package, add this feed to your NuGet sources:

Watch the presentation and view the slides on Channel 9.

Android

public void ShowHistory()
{
    if (_history == null)
    {
        // #1 Initialize Forms.Init(Context, Bundle)
        Forms.Init(this, null); 
        // #2 Use it with CreateFragment(Context)
        _history = new HistoryPage().CreateFragment(this);
    }


    // And push that fragment onto the stack
    FragmentTransaction ft = FragmentManager.BeginTransaction();

    ft.AddToBackStack(null);
    ft.Replace(Resource.Id.fragment_frame_layout, _history, "history");
    
    ft.Commit();
}

iOS

Call Forms.Init() before creating the UIViewController.

public void ShowHistory()
{
    if (_history == null)
    {
        // #2 Use it
        _history = new HistoryPage().CreateViewController();
    }

    // And push it onto the navigation stack
    _navigation.PushViewController(_history, true);
}

UWP Desktop

In this demo we placed the History Page inside a flyOut Frame. Call Forms.Init(e) prior.

var x = new HistoryPage().CreateFrameworkElement();

About

Weather demo showing Xamarin.Forms embedded in Xamarin.iOS, Xamarin.Android, and UWP non-Xamarin.Forms applications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published