The Xamarin Live Player is a fantastic tool to rapidly iterate and develop Xamarin applications without ever having to compile. One can easily update an application’s user interface and business logic to see it update right on your iOS or Android device. The Xamarin Live Player has been optimized for Xamarin.Forms-based applications, especially with XAML, but did you know that you can also leverage the Live Player with your iOS applications? Many iOS developers prefer to build their user interfaces and custom controls directly in C# without ever having to open a storyboard or XIB file. This allows complete control over the application, and the Xamarin Live Player works beautifully with any UIViewController or UIView as the base class.
Be sure to download the latest version of the Xamarin Live Player for iOS and enable the Xamarin Live Player.
- Visual Studio (Tools -> Options -> Xamarin -> Other)
- Visual Studio for Mac (Visual Studio -> Preferences -> Projects -> Xamarin Live Player)
You will then need to pair the Xamarin Live Player with Visual Studio, found under the Tools -> Xamarin Live Player menu, which will then bring up the pairing screen:
Live Run Current View
Let’s create a new custom control that enables us to drag and drop around a circle on the screen. This is a custom control in the iOS project that will inherit from UIView:
public class CrazyCircleView : UIView
CGPoint location = new CGPoint(100, 200);
CGSize size = new CGSize(75, 75);
UIColor background = UIColor.Purple;
BackgroundColor = background;
public override void TouchesMoved(NSSet touches, UIEvent evt)
//Grab touches and update location
var touch = touches.ToArray();
location = touch.LocationInView(this);
public override void Draw(CGRect rect)
//Set background color and circle color and draw
var c = UIGraphics.GetCurrentContext();
c.FillEllipseInRect(new CGRect(location, size));
With new control in place, we can select the new Live Player device that we paired as the deploy target. There are several options to run this view, including right-clicking and finding Live Run in the context menu, using hotkey (Shift+ALT+F5) in Visual Studio 2017, or by going to the Live Run Current View mode in Tools -> Xamarin Live Player in Visual Studio 2017 or Run -> Live Run Current View in Visual Studio for Mac.
There you have it! The custom control is now running inside Xamarin Live Player. You’re free to modify any of the user interface code or logic and have it update in real time on the device.
Be sure to subscribe to The Xamarin Show on Channel 9, where my guests and I discuss all things Xamarin each week. This week is a special Snack Pack episode, where I discuss this very subject: