Weather demo showing Xamarin.Forms embedded in Xamarin.iOS, Xamarin.Android, and UWP non-Xamarin.Forms applications.
HTML C#
Switch branches/tags
Nothing to show
Clone or download
Permalink
Failed to load latest commit information.
Weather
art
.gitignore
README.md added NuGet source to Readme May 17, 2017

README.md

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();