Disclaimer: this is an automatic aggregator which pulls feeds and comments from many blogs of contributors that have contributed to the Mono project. The contents of these blog entries do not necessarily reflect Xamarin's position.

December 2

Optimizing Android Apps for Multi-Window Mode

One of my favorite features in Android 7.0 Nougat is support for multiple applications running at the same time with the new Multi-Window mode. When the user has an application open and long presses on the app switcher button, they can select a second application to put side by side, which opens up new scenarios, such as dragging and dropping content. On tablets and other larger devices, this also enables a new freeform mode that allows applications to be fully re-sized. Out of the box applications should be able to take advantage of this new mode, as Android Activities will automatically re-size to the correct proportions when the app enters this mode. Here are two Xamarin.Android applications in the new Multi-Windows mode, one built with Xamarin.Forms and the other built with traditional Xamarin.Android.


As you can see, out of the box Multi-Window mode should be supported in your app, however, there are a lot of other optimizations that you can add that will delight your users.

Application Configuration

There are a few easy settings to enable and disable Multi-Window mode for your entire application for a single Activity when you compile against API 24.

If you’re using a sub-classed Application, you can add the ResizeableActivity attribute:

//Entire application does not support split mode
[Application (ResizeableActivity = false)]

//Main activity support split
[Activity(Label = "Monkeys",
        ResizeableActivity = true,
        MainLauncher = true,
        LaunchMode = LaunchMode.SingleTop,
        Icon = "@drawable/ic_launcher")]
//Detail activity does not support split
[Activity(Label = "Details",
        Name = "com.refractored.monkeysapp.DetailsActivity",
        ResizeableActivity = false,
        LaunchMode = LaunchMode.SingleTop,
        ParentActivity = typeof(MainActivity))]

If this is set to true, the activity and application can be launched into split-screen and freeform modes. If you specify this on a single Activity and the user navigates to it, then the new activity will go back into full screen mode. If you’re targeting API 24 and don’t set this attribute, the default will be true.

Launching Activities Side-by-Side

Another neat feature is the ability to launch side-by-side if the user is already in a split-screen session by adding a few flags to your intent before starting the new Activity:

var intent = new Intent(this, typeof(DetailsActivity));
//Request that the new Activity launches adjacent if possible
//Required for adjacent activity mode
//If you would like a new instance of an existing activity to be created.


Activity Configuration

Starting with Android 7.0, there’s a new Layout attribute that you can add to any Activity class that specifies additional parameters when the Activity is in Multi-Window mode. Here’s an example of specifying location along with the minimum and default dimensions when the Activity is launched into freeform mode:

[Activity(Label = "Monkeys",
        ResizeableActivity = true,
        MainLauncher = true,
        LaunchMode = LaunchMode.SingleTop,
        Icon = "@drawable/ic_launcher")]
    [Layout (DefaultHeight = "500dp",
             DefaultWidth = "600dp",
             Gravity ="top|end",
             MinHeight = "450dp",

Detecting Multi-Window Mode

Sometimes you may want to enable or disable parts of your user interface or functionality when the user enters Multi-Window mode. You can easily detect the new IsInMultiWindowMode boolean on any Activity.

  //Enable or disable functionality

Additionally, you can be notified when the user enters or exits Multi-Window mode by overriding the OnMultiWindowModeChanged method:

public override void OnMultiWindowModeChanged(bool isInMultiWindowMode)

Learn More

When optimizing for Multi-Window mode, there are a few other considerations to keep in mind, such as supporting drag and drop and all of the different types of configurations that users may attempt to launch your app in. Be sure to read through the official Android documentation on Multi-Window mode for a full testing check-list.

The post Optimizing Android Apps for Multi-Window Mode appeared first on Xamarin Blog.

Driving a PITA merge conflict to the release branch

Everything was green and working automatically while merging a feature branch to our latest release branch. In fact, I was about to meet my colleagues in the coffee room for a break, but... Ouch! A big red conflict involving a lot of lines appeared. At first glance, I have no idea what happened to the conflicting file. Cancel the coffee break? Hold on, not yet, not today!

Let me show you the steps I followed to solve a non-trivial merge conflict with Plastic SCM and have the feature branch integrate and checked-into the release branch. For this purpose, I used some 2nd-class-citizen features in Plastic that definitively I have to promote to 1st class after this experience.

December 1

Xamarin Developer Events in December

It’s been a fantastic year for the Xamarin Community, with over 100 user groups globally organizing more than 1,100 meetups and 136 Xamarin Dev Days, and after all of the awesome announcements at Microsoft Connect(); 2016, it’s no wonder Xamarin user groups around the world are getting together for a look at all of the new and improved tools for Xamarin developers! The end of the year is in sight, but there’s still plenty of events happening before we ring in the New Year. If you’re interested in diving into mobile development in C#, be sure to check out some of these great community events below.


Here are some of the Xamarin events happening around the world in December:

Xamarin Dev Days

  • Around the World! December
  • Join your local developer community for a free, full day of Xamarin and Azure mobile development training

North Florida Xamarin User Group 🇺🇸

  • Jacksonville, FL, December 5
  • Connect(); //2016 Recap for Mobile Developers

Boston Mobile C# Developers 🇺🇸

  • Cambridge, MA, December 8
  • Microsoft Connect Redux

Las Vegas Xamarin Developers 🇺🇸

  • Las Vegas, NV, December 14
  • Data Binding in Xamarin Forms Part 2

SĂŁo Paulo Developers br

  • SĂŁo Paulo, Brazil, December 14
  • Xamarin.Android and Material Design

Munich Mobile Xamarin & .NET Developers Group za

  • Munich, Germany, December 15
  • Xamarin Pizza & Beer – Connect(); Recap

Nashville .Net Developers 🇺🇸

  • Nashville, TN, December 15
  • Connect(); 2016 Recap for Mobile Developers

Find a Xamarin Developer Group in Your Area

If you don’t see an event above in your town or city, you can also use this map of Xamarin User Groups to find one near you.

Interested in starting your own Xamarin developer group?

We’re here to help! Take a look at a few of these useful resources:

Visit the Xamarin events page for even more Xamarin meetups, conferences, hackathons, and other events happening near you this month.

The post Xamarin Developer Events in December appeared first on Xamarin Blog.

November 30

Creating Platform-Specifics in Xamarin.Forms

Recently on the blog, Pierce introduced Platform-Specifics, which allow you to consume functionality that’s only available on a specific platform without having to implementing custom renderers or effects. With the use of a simple Fluent API, you can make platform-specific tweaks from shared code in Xamarin.Forms.

At the time of writing, Xamarin.Forms includes the following Platform-Specifics:

  • Blur support for any VisualElement on iOS.
  • A translucent navigation bar on iOS.
  • The ability to set the operating mode for a soft keyboard input area on Android.
  • Toolbar placement options on Windows.
  • A partially collapsible MasterDetailPage navigation bar on Windows.

In addition, vendors can create their own Platform-Specifics with Effects. An Effect provides the desired functionality, which is then exposed through a Platform-Specific. The result is an Effect that can more easily be consumed through XAML and a fluent code API.

In this blog post, I’m going to demonstrate how to expose an Effect through a Platform-Specific that adds a shadow to the text displayed by a Label. All the code can be found in a sample application. However, the blog post will focus on the implementation for the iOS platform.

Creating a Platform-Specific

The process for creating a Platform-Specific is:

  1. Implement the desired functionality as an Effect.
  2. Create a Platform-Specific class that will expose the Effect.
  3. Add an attached property to the Platform-Specific class to allow the Platform-Specific to be consumed through XAML.
  4. Add extension methods in the Platform-Specific class to allow it to be consumed through a fluent code API.
  5. Modify the Effect implementation so that the Effect is only applied if the Platform-Specific has been invoked on the same platform as the Effect.

Each item will now be considered in turn.

Implement the Desired Functionality as an Effect

In the sample application, the iOS project provides the LabelShadowEffect class, which adds a shadow to a Label by setting the following properties:

Control.Layer.CornerRadius = 5;
Control.Layer.ShadowColor = UIColor.Black.CGColor;
Control.Layer.ShadowOffset = new CGSize(5, 5);
Control.Layer.ShadowOpacity = 1.0f;

For more information about creating this Effect, see Creating an Effect and Passing Effect Parameters as Attached Properties.

Create a Platform-Specific Class

A Platform-Specific is created as a public static class:

namespace MyCompany.Forms.PlatformConfiguration.iOS
	using System.Linq;
	using Xamarin.Forms;
	using Xamarin.Forms.PlatformConfiguration;
	using FormsElement = Xamarin.Forms.Label;
	public static class Shadow
		const string EffectName = "MyCompany.LabelShadowEffect";
		static void AttachEffect(FormsElement element)
			IElementController controller = element;
			if (controller == null || controller.EffectIsAttached(EffectName))
		static void DetachEffect(FormsElement element)
			IElementController controller = element;
			if (controller == null || !controller.EffectIsAttached(EffectName))
			var toRemove = element.Effects.FirstOrDefault(e => e.ResolveId == Effect.Resolve(EffectName).ResolveId);
			if (toRemove != null)

The AttachEffect and DetachEffect methods will be used to add or remove the Effect, and will be invoked by additional code that’s added to the Shadow class.

Add an Attached Property

An attached property must be added to the Platform-Specific class to allow consumption through XAML:

public static class Shadow
	public static readonly BindableProperty IsShadowedProperty =
       BindableProperty.CreateAttached("IsShadowed", typeof(bool), typeof(Shadow), false, propertyChanged: OnIsShadowedPropertyChanged);
	public static bool GetIsShadowed(BindableObject element)
		return (bool)element.GetValue(IsShadowedProperty);
	public static void SetIsShadowed(BindableObject element, bool value)
		element.SetValue(IsShadowedProperty, value);
	static void OnIsShadowedPropertyChanged(BindableObject element, object oldValue, object newValue)
		if ((bool)newValue)
			AttachEffect(element as FormsElement);
			DetachEffect(element as FormsElement);

The IsShadowed attached property is used to add the effect to, and remove it from, the control that the Shadow class is attached to. The attached property registers the OnIsShadowedPropertyChanged method that will be executed when the value of the property changes. In turn, this method calls the AttachEffect or DetachEffect method.

Add Extension Methods

Extension methods must be added to the Platform-Specific to allow consumption through a fluent code API:

public static class Shadow
	public static bool IsShadowed(this IPlatformElementConfiguration<iOS, FormsElement> config)
		return GetIsShadowed(config.Element);
	public static IPlatformElementConfiguration<iOS, FormsElement> SetIsShadowed(this IPlatformElementConfiguration<iOS, FormsElement> config, bool value)
		SetIsShadowed(config.Element, value);
		return config;

The IsShadowed and SetIsShadowed extension methods invoke the get and set accessors for the IsShadowed attached property, respectively. Each extension method operates on the IPlatformElementConfiguration<iOS, FormsElement> type, which specifies that the Platform-Specific can only be invoked on Label instances from iOS.

Modify the Effect Implementation

The Effect implementation must be modified so that it can only be invoked from the same platform the Platform-Specific is implemented for:

if (((Label)Element).OnThisPlatform().IsShadowed())
	Control.Layer.CornerRadius = 5;
	Control.Layer.ShadowColor = UIColor.Black.CGColor;
	Control.Layer.ShadowOffset = new CGSize(5, 5);
	Control.Layer.ShadowOpacity = 1.0f;
else if (!((Label)Element).OnThisPlatform().IsShadowed())
	Control.Layer.ShadowOpacity = 0;

A shadow is added to the Label text provided that the IsShadowed attached property is set to true, and provided that the Shadow Platform-Specific has been invoked on the same platform that the Effect is implemented for. This check is performed with the OnThisPlatform method.

Consuming the Platform-Specific

The Shadow Platform-Specific can be consumed in XAML by setting the Shadow.IsShadowed attached property to a boolean value:

<ContentPage xmlns:ios="clr-namespace:MyCompany.Forms.PlatformConfiguration.iOS" ...>
  <Label Text="Label Shadow Effect" ios:Shadow.IsShadowed="true" ... />

Alternatively, the Shadow platform-specific can be consumed through the fluent code API:

using Xamarin.Forms.PlatformConfiguration;
using MyCompany.Forms.PlatformConfiguration.iOS;

This results in a shadow being applied to the text displayed by a Label:


Wrapping Up

The result of exposing an Effect as a Platform-Specific is that the Effect can be more easily consumed through XAML and through a fluent code API.

For more information about consuming Platform-Specifics, see Consuming Platform-Specifics. For more information about creating Platform-Specifics, see Creating Platform-Specifics.

The post Creating Platform-Specifics in Xamarin.Forms appeared first on Xamarin Blog.

November 29

Live Webinar | Getting the Most out of iOS 10 and Android N

The newly released iOS 10 and Android N(ougat) operating system updates are great opportunities for mobile developers to add new features to their mobile apps that make them stand out. Join Mike James and James Montemagno, Microsoft Program Managers of Mobile Developer Tools, for a webinar on December 8, 2016 at 10:00 am PT / 1:00 pm ET / 5:00 pm GMT as they guide you through the latest enhancements in these releases.

Mike will discuss iOS 10’s new features, including new App Extensions, CallKit, iMessage Apps, and the new SiriKit. For Android Developers, James has you covered with Android N’s notification enhancements, multi-window support, important environment changes, and the latest revisions of the Android Support Libraries and Google Play services to add to your app.

ios and android n

During this webinar you will:

  • Discover new iOS 10 and Android N features, and how they impact your apps.
  • Review code samples and hear best practices for accessing the new APIs.
  • Explore how to maximize code-sharing between projects and ensure backward compatibility while leveraging platform-specific APIs.

Register at the link below to join us on December 8, 2016 at 10:00 am PT / 1:00 pm ET / 5:00 pm GMT.


The post Live Webinar | Getting the Most out of iOS 10 and Android N appeared first on Xamarin Blog.

November 28

Say Hello to the Xamarin Profiler

As developers, we have many tools at our disposal to help catch problems in our code (and protect our sanity); for example, IDE features such as IntelliSense find errors as we type, a debugger gives us a window into the app when it’s running, and a profiler, in turn, shows us how our app is using resources and where it could be more effective. The Xamarin Profiler is currently the only way to profile managed (C#) code and find memory and performance issues in Xamarin applications. It can also be paired with native profilers, like Xcode Instruments and Android Monitor, to ensure better app behavior and performance.

Last week at Microsoft Connect(); we announced the first stable release of the Xamarin Profiler, available today from the Xamarin download page as part of the full Xamarin installation for MSDN Enterprise subscribers or download the standalone installer here. We have designed beautiful, native Profiler apps for both Mac and Windows to help collect and interpret profiling data.

Profiler on Windows

Profiler on Windows

Launching the Profiler

To start a profiling session, launch an application on device or simulator with the Xamarin Profiler attached. In Visual Studio, open your Xamarin project and choose Analyze > Xamarin Profiler to begin the session. In Xamarin Studio and Visual Studio for Mac, choose Run > Start Profiling.

Xamarin Profiler sessions can also be saved in the mlpd format (Mono Log Profiler Data). Double-clicking on an mlpd file will open it in the Xamarin Profiler. These files can be moved between Windows and Mac.


When Xamarin Profiler launches, it will ask you to select an instrument or group of instruments to gather data about your app. Each instrument gathers certain information about an application to help diagnose different types of problems. The Xamarin Profiler comes with three instruments: Allocations, Time Profiler, and Cycles. Let’s dive into each one to learn how it can help us build better apps.


The Allocations instrument shows us how much memory our app is using and what it’s using it for. The allocations tab has a list of all of the objects created during the lifetime of the app, with the details panel on the right providing additional filters, statistics, and a chart on the overall breakdown of memory usage:

Profiler on Mac

Profiler on Mac

We can further filter the list of Allocations to find objects useful to us. For example, we can search for objects from our code by searching for our namespace. The Xamarin Profiler marks our objects in blue:

Profiler on Mac

Profiler on Mac

Another way to filter Allocation data is to limit the information to a particular segment with the selection tool. The selection tool lets us highlight a section of data to focus on. This will limit the Allocations list to the objects allocated during the selected time interval:

Profiler on Mac

Profiler on Mac

The Allocations instrument also features a call tree, which displays memory usage grouped by method call. We have the option to view the call tree separated by thread as well as inverted, which shows memory usage at the most granular level first and works its way up the call stack:

Profiler on Mac

Profiler on Mac


A nice feature of the Allocations instruments is snapshots, the ability to list all of the objects in our app at a point in time. We can take a snapshot at any point during the profiling session by clicking on the camera icon in the Profiler controls on the top left. The red lines in the console mark the snapshots in the profiling session:

Profiler on Windows

Profiler on Windows

Double-clicking on a snapshot reveals the objects that are in memory at the time. Choosing Only New Objects in the display options limits the objects displayed to the delta between the previous snapshot and this one. This gives us a sense of what was created between two points in time:

Profiler on Windows

Profiler on Windows

Time Profiler

The Time Profiler uses sampling to determine where our app is spending the most time. Sampling is a lightweight performance profiling method that polls the application at regular intervals to determine what code is being executed and then forms a hypothesis for how long different parts of our program take to execute.

Inside the Xamarin Profiler, the call tree in the first tab is the same call tree as the Allocations tab, but instead of breaking down memory usage by method, it shows how much time was spent in each method.

In the second tab, the sample list gives us a breakdown of the sampling results:

Profiler on Mac

Profiler on Mac


The Cycles instrument gives a written and visual representation of circular references between objects, making it particularly useful for detecting native reference cycles, or circular references between objects that cross the boundary between the native and managed world. These types of cycles are important, because they prevent the objects involved from being picked up by the garbage collector.

The Xamarin Profiler provides a list of cycles under the Roots & Cycles tab. We are primarily concerned with cycles involving objects in our own code. If a cycle is detected, Xamarin Profiler will list the root object in the list on the left and draw a graph on the right of all the objects involved in the cycle. The root of the cycle is pictured in purple, with the dependencies between objects represented by arrows:

Profiler on Windows

Profiler on Windows

For more information on Cycles, refer to our simple example app for native reference cycles, and James Clancey’s Guide to Cross-Platform Performance with Xamarin, which provides details on how cycles form and how to fix them.



The post Say Hello to the Xamarin Profiler appeared first on Xamarin Blog.

November 26

OS X Branch Explorer learns to filter branches

BL793 comes with another great feature for OS X users: now you can filter branches in the Branch Explorer! It is an added capability on top of the “inclusion/exclusion rules”. It works as follows:

November 24

Move changesets to a different branch

Release BL793 (short of – BL means baseline) brought a great new feature: moving changesets to a different branch! This way we close the Top-1 User Voice request from our users.

Do you know when you are working on something, you checkin, and then you realized you made the checkout on the wrong branch? Like directly on “main” instead of your task branch? Painful, uh?

Well, now the pain is gone, watch how simple it is to solve the issue:

Available on OS X, Linux and Windows, and also from the command line using the refurbished “cm changeset” command.


November 23

Introducing Xamarin.Forms 2.3.3: Native View Declaration and Platform Specifics

Today, we released Xamarin.Forms 2.3.3 to stable. In addition to a plethora of bug fixes, this release includes exciting new features, such as native view declaration and Platform-Specifics, which make it even easier to add platform-specific controls and functionality to your Xamarin.Forms apps.

Native View Declaration and Bindings

Xamarin.Forms already provided many different ways for you to add native controls to apps, from custom renderers and effects to native embedding. Native view declaration allows you to add bindable native iOS, Android, and Windows 10 controls directly to XAML, without requiring any additional configuration.


Often, developers want to add functionality that is only available on certain platforms to their Xamarin.Forms apps. Exposing this functionality within Xamarin.Forms isn’t tenable, as issues arise on platforms where the behavior isn’t implemented. To solve this issue, we’ve created something we call Platform-Specifics, which allow you to take advantage of awesome native functionality from within shared code via a fluent code API or XAML. Today, five Platform-Specifics are built into Xamarin.Forms, with even more to come in future releases.

Try Xamarin.Forms 2.3.3 Today

You can grab Xamarin.Forms 2.3.3 by updating your Xamarin.Forms NuGet in all projects, including platform projects and PCL (if applicable). Be sure not to “Update All”, as this updates all NuGets, and can break Xamarin.Forms’ compatibility with the Android Support Libraries. Updating the Xamarin.Forms NuGet will take care of this for you, if compatible updates are available.

The post Introducing Xamarin.Forms 2.3.3: Native View Declaration and Platform Specifics appeared first on Xamarin Blog.

November 21

Live XAML Previewing with the Xamarin.Forms Previewer

One of the most time-consuming parts of development is the the build and run cycle, or the time between writing a line of code and seeing it execute. Real-time feedback makes development faster, easier, and more fun for developers. The Xamarin.Forms Previewer renders a live preview of a page side-by-side with the XAML markup, allowing you to see your user interface come to life as you type.

We’re happy to announce the Xamarin.Forms Previewer for Visual Studio and Visual Studio for Mac as part of our Microsoft Connect(); 2016 release. Today, we’re delivering the same core set of features that we previewed at Xamarin Evolve earlier this year, now available on both Mac and Windows.

Installing the Xamarin.Forms Previewer

The Xamarin Forms Previewer is available by default with Visual Studio 2015 and 2017 RC with Xamarin installed. On the Mac, it’s available by default in Xamarin Studio and the Visual Studio for Mac preview, with the latest Xamarin.iOS and Xamarin.Android installed. Latest-and-greatest Xamarin.Forms NuGet is recommended; at least 2.3.2 is required. The Previewer is available for free with a Community license.

Using the Previewer

The Previewer works on any ContentPage, ContentView, or ViewCell in a Xamarin.Forms application. You can create a new Xamarin.Forms app from template or open an existing application. Make sure your app uses XAML for user interface files. Do an initial build of your app before opening the Previewer – an initial compilation is required for the Android preview to work. It’s also required during development for the Previewer to pick up any UI changes and resources outside of the XAML.

Double-click on a XAML file to launch the Previewer in Xamarin Studio or Visual Studio for Mac. You should see a split view with your XAML on the left and a preview on the right:

Previewer in Xamarin Studio.
If you don’t see the design surface on the right, press the Preview button at the top right of the text editor to toggle the Previewer.

To launch the Previewer in Visual Studio, select View -> Other Windows -> Xamarin.Forms Previewer, or search for “previewer” in the search bar. This will open a tool window for the Previewer. The tool window can then be docked next to the editor:

Previewer in Visual Studio

The Design Surface

The Previewer has tools that help ensure your UI looks good for your users. The design surface allows you to switch between:

  • iOS and Android
  • Phone and Tablet
  • Landscape or Portrait

Previewer design surface, error reporting, and XAML intellisense
Zoom controls are also available on the design surface to help you fine tune your design. On a Mac, the Xamarin.Forms Previewer also supports trackpad zoom gestures.

More Resources

For more information on getting the most out of the previewer, check out these guides from our team and community:

The Previewer is a valuable tool to speed up Xamarin.Forms development, and we hope you use it as part of your everyday development workflow, as well as continue to reach out to us with feedback and ideas!

The post Live XAML Previewing with the Xamarin.Forms Previewer appeared first on Xamarin Blog.

Merging in Plastic Cloud is now available

We are happy to announce that it is now possible to merge branches using a Plastic Cloud server (it applies both to Team + Cloud and Cloud Edition).

We initially disabled it because we wanted to encourage users to stick to the distributed model (push/pull), but you sent us so many requests asking to enable it that we decided to release it.

Merging in Plastic Cloud enables the simpler “centralized workflow” not only for artists using Gluon but also for coders. Now nothing stops you to start creating branches, checkin changes and finally get child branches integrated back to main.


Monologue is a window into the world, work, and lives of the community members and developers that make up the Mono Project, which is a free cross-platform development environment used primarily on Linux.

If you would rather follow Monologue using a newsreader, we provide the following feed:

RSS 2.0 Feed

Monologue is powered by Mono and the Monologue software.