Friday, November 13, 2015

How to Preview your Xamarin.Forms XAML in Xamarin Studio

In my work as a Customer Success Engineer at Xamarin, I demo the tools we provide daily. One that has gained immense popularity since launch has been, without a doubt, Xamarin.Forms. For those of you new to Xamarin development, Xamarin.Forms is a framework that enables you to write your mobile UI for Android, iOS and Windows phone in a shared code layer using either C# or XAML. Many developers see this as a real asset as greater code share suggests shorter development times and getting your app faster to market. XAML based UI development is also something that WPF and C# developers are already familiar with so that means their experience will help them get up and running with mobile sooner.

With that in mind, one thing that developers desire is rapid feedback and development. At the time of this writing Xamarin.Forms currently is a programmatic solution only. That means, no visual designer or previewer to view your UI in progress. That means that the only way to ensure your UI looks good is to build and deploy your app to either an emulator or physical device. While certainly a possibility, this is not the fastest process, especially if you are trying to make minute changes and get immediate feedback.


One solution to this that has been made available is a tool call the Xamarin.Forms Player, written by Daniel Cazzulino, who also happens to be a developer at Xamarin. What this tool does is installs a plugin to Visual Studio that allows you to pair your Visual Studio instance to either an emulator or device. Then, while you are writing the XAML portion of your application, you can actually quickly preview the results live without doing a full build and deployment of the application. This serves as a great solution to many developers. While the Visual Studio add-in has been available for a while, I was recently made aware of this also being published as an Add-In for Xamarin Studio and wanted to write a quick guide on how to get it set up.

From what I understand about the tool, the Forms Player works as a pub/sub application where multiple devices will subscribe to an IDE through a paired code between your IDE and an configured application running on device. Then, as you are developing your XAML you can quickly do a compile and publish. When the IDE publishes an update, each subscriber running will update and display the result. Really cool.

There are two main parts to getting this set up

I. Install the Add-In within Xamarin Studio (On Mac)

Select Xamarin Studio -> Add-In Manager -> Gallery Tab. From there search for Forms Player, it should appear under Mobile Development

II. Create and Install a Forms Player application on device.

Here is where we set up the subscriber side of things. There are a few ways you could do this, including compiling the code from GitHub and installing it, but this approach is pretty simple.

1) Create a new cross platform Xamarin.Forms application. I would name it something like "Forms Player" or maybe equally memorable. PCL or Shared Project should be fine.

2) Add the Xamarin.Forms Player NuGet to your Android and iOS Targets. Right click both Android and iOS Projects-> Add-> Add NuGet Packages. Make sure in the bottom right you check the "Show pre-release" box.


3) Update  new App () in MainActivity.cs and AppDelegate.cs to be new Xamarin.Forms.Player.App ()






As a side note, you may need to modify some of the built references on the iOS project. When I set this up, it complained, initially, about duplicate references to System.Runtime, System.Threading and System.IO. Removing them from the References-> From Packages folder got it running fine.

4) Deploy this application to the devices/emulators you want to support. You will see a Home screen like this:

  
iOS on left, Android on Right
III) Start debugging your app

Now that you have these installed, what you will do is pair them. You do this by selecting the Forms Player menu and select Connect. This will create a running Session ID, which you will input in the running application you have previously installed above.

Open up the Forms application you want to work on. When you open the .xaml file, you will notice that the "Publish" option from the Forms Player menu will no longer be greyed out. Each time you select publish, or hit the hotkey, while you have a .xaml file loaded in your IDE, it will load that current XAML to any device with the app running and session paired, and then preview it.

And there you go! Hopefully you found this useful and it will help you build and ship higher quality Xamarin.Forms apps faster.

25 comments:

  1. Hey, have you seen this?

    http://gorillaplayer.com

    ReplyDelete
    Replies
    1. I have, don't have an invite currently however. Curious to see how it runs

      Delete
  2. Hi James,

    I'm getting an error with XamlC task.





    The error says that the "XamlCTask" doesn't found. Any ideas about this error?

    Thank you so much!!

    ReplyDelete
  3. Currently the most sought after technology for cross platform mobile development is Xamarin

    ReplyDelete
  4. Microsoft office setup is the software setup file with this setup file you can install on your computer and some of the supported device to use Microsoft office.
    www.office.com/setup
    office.com/setup
    office com setup

    ReplyDelete
  5. office.com/verify, www office com setup, office.com/myaccount, Office Com Setup, office.com/productkeycard, Office Setup, setup.office.com, Office Com Set Up, office 2017 download, Office Setup Enter Product Key,
    office.com/setup

    ReplyDelete
  6. Microsoft Office includes a wide range of desktop applications such as Word, Excel, Access, PowerPoint, Groove, OneNote, Publisher and Outlook which helps you to complete the various task easily such as writing a letter, sending an email and creating PowerPoint presentation.
    office.com/setup

    ReplyDelete
  7. McAfee Installation is such an easy or simple process as you have to make sure that above-mentioned prerequisites should be fulfilled before getting started with the McAfee Activation Process.
    mcafee.com/activate

    ReplyDelete
  8. office.com/setup - If user wants to use the Microsoft Office online then open the web browser you are using on your system and visit office.com/setup. Login to your Microsoft account with your registered email id and password. The data which you have stored on OneDrive or DropBox, you can access and modify it.
    office.com/setup

    ReplyDelete
  9. Norton has vast range of software such as Norton security premium, Norton Security Basic, Norton Security Standard, Norton Internet Security, Norton 360, and Norton Antivirus etc, which provides the protection from threats and identity theft and monitors the antimalware. The security or protection provided by the Norton is better than any other security tool, because of it's unique structure and easy to use interface it is very popular among the users.
    norton.com/setup

    ReplyDelete
  10. Get Started to activate office setup by visiting office website and enter office product key to verify it.If you already entered a product key and looking for your software, go to office.com/myaccount directly and click on my account page for office installation and manage your subscription.If you have not entered office product key yet, Follow steps for setup.If you face any problem during any step, Do not worry we will help you.

    office.com/setup

    ReplyDelete
  11. Microsoft Office includes a wide range of desktop applications such as Word, Excel, Access, PowerPoint, Groove, OneNote, Publisher and Outlook which helps you to complete the various task easily such as writing a letter, sending an email and creating PowerPoint presentation.

    Office.com/verify,

    ReplyDelete
  12. McAfee Installation is such an easy or simple process as you have to make sure that above-mentioned prerequisites should be fulfilled before getting started with the McAfee Activation Process.

    mcafee loginount

    ReplyDelete
  13. If user wants to use the Microsoft Office online then open the web browser you are using on your system and visit office.com/setup. Login to your Microsoft account with your registered email id and password. The data which you have stored on OneDrive or DropBox, you can access and modify it.

    office.com/setup

    ReplyDelete
  14. Norton has vast range of software such as Norton security premium, Norton Security Basic, Norton Security Standard, Norton Internet Security, Norton 360, and Norton Antivirus etc, which provides the protection from threats and identity theft and monitors the antimalware. The security or protection provided by the Norton is better than any other security tool, because of it's unique structure and easy to use interface it is very popular among the users.
    norton.com/setup

    ReplyDelete
  15. office setup
    Use of MS Office is also simple and the user can learn the use of it easily. Online help option is also available in all application of the MS Office which provides an instant guideline.
    office.com/setup

    ReplyDelete
  16. Microsoft Office is a suite of desktop productivity applications software that is designed specifically to be used for office or business purpose.
    www.office.com/setup
    Gmail Tech Help

    ReplyDelete
  17. Norton Utilities can be broadly defined as a utility software suite, which is designed to provide complete assistance for analyzing, configuring, optimizing and maintaining a system. While downloading, installing or configuring the antivirus on your device, you may face an error. . Our technicians will provide you an instant support for Norton Product.

    Why Choose us:

    - Certified Technicians
    - 24/7 Availability
    - Best Services
    - Prompt Delivery
    www.norton.com/setup

    ReplyDelete
  18. Get Started to activate office setup by visiting office website and enter office product key to verify it.If you already entered a product key and looking for your software, go to office.com/setup directly and click on my account page for office installation and manage your subscription.If you have not entered office product key yet, Follow steps for setup. Do not worry we will help you.

    www.office.com/setup

    ReplyDelete
  19. Garmin Express gives you the notifications as soon as the updates are available for your Garmin device. You can also sync with the Garmin connect by using the Garmin Express. Garmin Express helps you to transfer or upload your daily activities and data to your Garmin Connect account.

    garmin.com/express

    ReplyDelete
  20. McAfee Installation is such an easy or simple process as you have to make sure that above-mentioned prerequisites should be fulfilled before getting started with the McAfee Activation Process.

    mcafee.com/activate

    ReplyDelete