May 26, 2016 10:05 GMT

Xamarin.Forms Behaviors: New Actions

My Behaviors Library for Xamarin.Forms is a PCL I’ve created that can be consumed by Xamarin.Forms applications, and can be downloaded from GitHub and NuGet. The library has the notion of behaviors and actions. A behavior is attached to a control and listens for something to happen, such as an event firing. When the “something” happens, it triggers one or more actions, such as invoking a method or command. Actions are invoked by behaviors and executed on a selected control.

I’ve recently added a number of new actions to the library, to support animations. The actions are:

  • FadeAction
  • RotateAction
  • ScaleAction
  • TranslateAction

The advantage of using these actions is that it’s possible to invoke animation through XAML, rather than having to use C#. In addition, when combined with behaviors, compound animations can easily be invoked through XAML when a behavior occurs, such as an event firing, or a piece of data changing.

Stay tuned over the next few weeks for details of how to consume these actions.

May 25, 2016 8:52 GMT

View Model Page Navigation with MVVM Light

When you move from code behind to a View Model (as you should, if only to makeBlank freeway sign ready for your custom text testing easier) certain challenges arise, such as: how do I navigate to another page?

Fortunately, MVVM Light provides a Messaging bus, that makes it easy to send messages from a View Model to a page (or to another View Model).  This can be over done but when used judiciously it makes the very difficult into the very easy.

The following solution was improved enormously by Eric Grover, my favorite MVVM Light Guru after Laurent 🙂

Begin by creating a parent for ContentPage (I called mine BaseViewPage).  Have your content pages derive from the new page.  In the new page we’ll register to receive Navigation Messages from the Messenger Bus

 

public BaseViewPage( )
  {
 
      Messenger.Default.Register<INavigationMessage>(
          this,
          HandleNavigation );
 
  }

Notice we need an interface, INavigationMessage and a method, HandleNavigation.

INavigationManager looks like this:

 

public interface INavigationMessage
  {
      Type PageType { get;  }
  }

This allows us to navigate to any type of page.  Its implementation is:

public class NavigationMessage<T> : INavigationMessage where T : Page
{
    public Type PageType
    {
        get { return typeof(T); }
    }
 
}

This nicely forces the type to be a Page.

Here’s HandleNavigation, which also goes in the BaseViewPage:

 

public async void HandleNavigation( 
    INavigationMessage navigationMessage )
   {
 
       var target = Activator.CreateInstance(
               navigationMessage.PageType);
 
       await Navigation.PushAsync( (ContentPage) target );
   }

Nicely generic, which is just what we want.

Now we’re ready to use this.  Let’s say we’re in MyPageViewModel and we want to navigate to YourPage (xaml).  We write:

 

var message = new NavigationMessage<YourPage>();
Messenger.Default.Send( message );

Slick, eh?

May 23, 2016 5:02 GMT

Customize the iOS Keyboard with Xamarin

You can customize the iOS Keyboard with Xamarin.

Nearly all applications require that users interact with your app via a keyboard. It could be a search bar, a text field, or something else -- users typically use the keyboard in some way for input. iOS comes with different types of keyboards that can solve just about any need, but there are times when some additional feature would be great. In Google's Gmail app for iOS, for instance, maybe you'd like to make things a bit easier by adding e-mail addresses for .net, .org, and other domain suffixes. This article will look at how to modify the existing iOS Keyboard to better fit the needs of the application.

May 21, 2016 12:46 GMT

Yet Another Podcast #154 – Dan Wahlin on Typescript and Angular 2

Dan Wahlin founded Wahlin Consulting which provides consulting and training IMG_0510services on Web technologies.

He has also published over 10 developer courses on Pluralsight.com and Udemy.com including the new Docker for Web Developers course. Dan is a Docker Captain, Google GDE, Microsoft MVP and Regional Director and speaks at conferences and user groups around the world.

Dan has written several books on Web technologies, hundreds of technical articles and blog posts and runs the Web Weekly newsletter – a great way to stay up on the latest technologies. Follow Dan on Twitter @DanWahlin.

 

 


May 21, 2016 12:00 GMT

Xamarin Mac Build Host Versioning

Before I eventually get to the protocol layer underlying the new build host in Xamarin 4 (as promissed in a previous post that introducing it, I wanted to mention how we architected it from the get go for a key scenario that we’ll want to enable in the future: side-by-side (SxS) versioning.

Why would I care about SxS?

Visual Studio update and release cadence has been accelerating, and we want to support users that are on the bleedging edge. At the same time, there is a very real world of users that are still on Visual Studio 2012 or 2013 that we also need to support. At the same time, Xamarin also has a different release cadence than Visual Studio, and it even supports the concept of Stable, Beta and Alpha channels, as well as the occassional web preview for new features.

The way this currently works in Xamarin is you install from whichever channel (or VS-bundled version), and you get a single Xamarin install that applies to all IDEs you have installed in the machine. This is clearly not SxS ;). That’s not at all how Visual Studio itself works, where you can have an early CTP of vNext (i.e. Dev15 right now) while using a very stable Visual Studio 2013 Update 5 for your daily work.

This is obviously a good place to be: you get early feedback on upcoming versions, with minimal disruption of your daily work environment. We want to get there for Xamarin for Visual Studio (XVS from now on) too.

Step by step

The first part of such a SxS story, and you might even say the most critical one, is the build host.

The build host is tightly bound to the matching XVS version, since it’s a core part of the iOS MSBuild infrastructure, and there must be an exact match of tasks inputs/outputs, serialization, connectivity and the like.

So it was clear from the beginning that we needed to version the install location on the Mac for the build host and all its agents. For versioning, we use the very awesome (if I might say so myself) GitInfo package which versions all assemblies automatically without patching AssemblyInfos ;). We use the semver-like version on the build host (we call it the “broker” for reasons that will be evident when we talk about the protocol ;)) and the agents to determine which process to talk to on the Mac side.

NOTE: our version numbers are like [platform version].[cycle counter within platform].[service release].[build], so currently, our latest stable release as of this writing is Xamarin 4, shipped in our first “cycle 6” release, Service 4, so it’s: 4 (platform) .0 (cycle 6) .4 (service release 4) .4 (fourth build of the bits after we branched for the release. The upcoming cycle7 release is 4.1.0.x (4 = same major platform version, 1 = one cycle on top of the original cycle 6 when it shipped first, 0 = first release, x = whatever build)

When XVS detects that the specific version of the broker that bundles isn’t installed on the Mac, it will automatically deploy a new broker and all agents. So if as a user you use VMs to isolate your production vs “cutting edge” environments, and connect with them to the same Mac, the build host will happily install side-by-side with other build hosts.

NOTE: this does not necessarily mean that Xamarin.iOS or Xamarin.Mac on the Mac support this kind of side-by-side right now, it’s just that from XVS’ point of view, we do. We hope to get there eventually.

Updating the Build Host

You may have noticed (or figured out if you read carefully), that there is no self-update process from the broker/build host itself. Since the whole install/run/update is drive by XVS, there is no need for it, and this significantly simplifies the user experience.

On the Mac, you can notice this versining scheme when looking for logs, which are located at ~/Library/Logs/Xamarin-[MAJOR.MINOR], as well as the actual broker and agents, installed under the $HOME/Library/Caches/Xamarin/XMA (XMA stood for “Xamarin Mac Agent” originally). You can see a structure like the following there:

Broker/
    ...
    4.0.4.4/
Agents/
    IDB/
        ...
        4.0.4.4/
    Build/
        ...
        4.0.4.4/
May 20, 2016 10:14 GMT

TypeScript and Angular 2

AngularAfter attending ng-conf a couple weeks ago, and taking a terrific workshop with John Papa and Dan Wahlin, and spending time talking with them and with Ward Bell (who is responsible for the Angular 2 documentation), I’ve decided to go all-in with Angular 2 for my Web work.

Angular 2 is written in and all the samples and documentation are written in TypeScript.  Thus, TypeScript is my next language of choice.  This should be pretty straight forward, as the hard part is OOP, which we C# programmers are already comfortable with.

I’ll try to document my travels through these technologies as I go.  Truth is that I’m fully employed with Xamarin work, so this will come in fits and starts, but I’ll do what I can to keep up a cadence.

Looking forward to it.

Photos from ng-conf

May 19, 2016 9:44 GMT

Global Resources in Xamarin.Forms

First, when I checked Google, all I could find was articles saying this can’t be done.  Humbug.  Thanks to Roger Peters and jFarrell I got it done (well, they did and then I did, but now you will).

Here are the steps (and they are pretty easy)

  • Create a normal XAML file named App.xaml.
  • This will automatically create a file named App.xaml.cs
  • Copy from App.cs to App.xaml.cs and delete App.cs
  • In App.xaml set the ContentPage to be an Application and create a resource dictionary
<?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="eSiteMoble.App">
 
 
  <Application.Resources>
    <ResourceDictionary>
  • Add the keyword Partial before class in App.xaml.cs
  • Add InitializeComponent to the constructor (this is critical)

Hey! Presto! your resources are available to any page…

<Label Text="Remember Me?"
             TextColor="{StaticResource TextForegroundColor}"

Easy as cake. Piece of Pie.

May 16, 2016 3:13 GMT

ADAL and how to sign in with Microsoft accounts in Xamarin.iOS

One the latest bits we added to HealthClinic.biz suite is Azure’s Active Directory Authentication (ADAL from now on). Basically, you can authenticate users by their Microsoft account, and let them access the app or not. You can do some other things, but our mainly goal was that one. For instance, we added also Touch ID so your fingerprint is saved to avoid entering the credentials once and again. Superb.

However, I got the feeling I should extract all that I learned into a simple sample (try to read it without spaces, new buzzword coming:-) ) just to clarify the concepts needed to achieve such authentication, plus best practices on how to handle, for example, recovering the session when waking the app up again from scratch.

MS Graph Auth app

MicrosoftGraphAuthSample does just that. And this’ the list of key points:

Read the entire article…


May 16, 2016 1:00 GMT

Xamarin and everything on Evolve 2016

My conversation with my good friend Fanie Reynders for a GeekFest episode about the past Evolve and everything that is announced there!

We cover iOS simulator remoting within Visual Studio 6:49, the all new XAML Previewer 10:41, themes, a quick look at Snppts 25:51 (my pet project, see my previous post here) and Xamarin Workbooks 34:20. Let’s spread some Xamarin love!

May 14, 2016 8:26 GMT

Xamarin.Forms Workbooks

As explained in the last post, it's easy to add Nuget packages to Xamarin Workbooks. My immediate reaction to this news was "I want to use Xamarin.Forms!" Unfortunately it's not immediately obvious how to get Xamarin.Forms into a Workbook... so here are the steps (for an iOS Workbook):

1. Add the Xamarin.Forms nuget (and reference the platform)

When you add the Xamarin.Forms Nuget, four assemblies will be referenced (including the iOS Platform assembly for Xamarin.Forms). The using statements need to be added too - don't forget to add the Xamarin.Forms.Platform.iOS namespace:


2. Create a Page and App as usual

In both classes it's a good idea to create public properties for elements you want to manipulate in the workbook.

This allows those controls to be referenced later in the workbook...

3. Hack the FormsAppDelegate

The biggest hurdle to getting Xamarin.Forms to run is that in a normal iOS app, the AppDelegate must be a subclass of FormsApplicationDelegate to wire up various bits of Xamarin.Forms. Peeking into the open-source, the key thing we need to do is set the RootViewController... the following code does the initialization we need to get a Workbook running:


WARNING: obviously this approach misses some of the other code implemented in FormsApplicationDelegate so some things might not work as expected. This is a bit of a hack :)

4. Run It

The public properties on the App and Page classes mean the workbook can manipulate those elements to demonstrate various Xamarin.Forms capabilities.



Try it out with the WorkbookFormsTest workbook:



Check out the more complex ListView1 workbook too:



p.s. the irony of included screenshots of code is not lost on me - but hey, it's actually a good reason to download and us Xamarin Workbooks to try these samples out :D
May 14, 2016 7:31 GMT

Xamarin Workbooks with Nugets

Xamarin Workbooks are getting better and better (check out the intro to Workbooks if you don't know what I'm talking about).

Nuget packages can now be added, meaning you can teach or demo almost anything in a Workbook :)

In the Workbook app, choose File > Add Package... to open the Nuget package explorer:


Then search for the Nuget and add to the workbook:


Try out this Json.NET Workbook example to see how it works


Coming up next - adding the Xamarin.Forms nuget!

p.s. for a video demo of Nugets in Workbooks, check out this community contribution on brax.tv
May 12, 2016 1:39 GMT

The many flavors of HttpClient

HttpClientHandler

When using Xamarin, you can use the standard .NET HttpClient. By default, HttpClient is Mono’s complete reimplementation of the entire HTTP stack. It is sufficient for many use cases but there are other alternatives out there that can be defined by selecting an alternative HttpClientHandler. For my Evolve talk, I put together an overview of the different HttpClientHandlers you can use:

HttpClientHandlers

CFNetworkHandler (iOS 6+) and the new NSUrlSessionHandler (iOS 7+, starting with Xamarin.iOS 9.8) are the handlers that utilize Apple’s native APIs instead of the Mono implementation. You can define which handler the HttpClient default constructor will use either in the IDE or by providing an argument to mtouch (e.g., --http-message-handler=NSUrlSessionHandler).

iOS options: HttpClientHandler

For Android, there is now AndroidClientHandler (starting with Xamarin.Android 6.1). There is no IDE option for defining the default handler yet but you can define it using the @(AndroidEnvironment) build action to define an environment variable XA_HTTP_CLIENT_HANDLER_TYPE to the value Xamarin.Android.Net.AndroidClientHandler.

Alternatively, you can use ModernHttpClient by handing a NativeMessageHandler to the HttpClient constructor which will also use native implementations for making HTTP calls.

SSL/TLS

The default Mono implementation does not support the newest (and most secure) TLS standard 1.2 while the native handlers do. To use TLS 1.2 with the Mono implementation, Xamarin.iOS 9.8 introduced the option to swap the TLS implementation with P/Invoke calls into the Apple’s TLS implementation. This can be selected either in the IDE or by adding the --tls-provider=appletls option to mtouch‘s options.

iOS options: TLS

For Android, there is no such option but it is expected that BoringSSL support will be added soon.

Here’s the summary slide I showed in my talk:

HttpClient comparison

Xamarin have actually gone through the trouble of reimplementing the TLS code to support TLS 1.1 and 1.2. However, it is expected that it will be abandoned because of security considerations in favor of the native platform implementations, just as Microsoft has done for Windows.

May 11, 2016 1:15 GMT

Using iOS and 1Writer as a Presentation Assistant

I've given a lot of talks over the years, with varying amounts of live coding and moving parts. For many of them it wasn't uncommon for me to have some sort of notes jotted down as an emergency reminder if my memory fails in the moment, and I always have local fallbacks for any network-dependent demos to avoid being completely hindered by bad connections.

When preparing for my talk at this year's Xamarin Evolve, I found myself in need of more than in previous talks. This talk was, by definition, completely network dependent, as well as totally dependent on a host of third party services I had no control over. Basically this was a nightmare scenario for me as a presenter, and made me question what I was smoking when I pitched the talk. In addition to the prospect of demo fails, I also found myself with far more things on my pre-flight checklist to remember to do before even beginning the presentation. My default way to write notes and lists is to use Markdown, which then lead me to:

I was surprised at the lack of good options I was finding after some initial searching, since it seemed like my needs were extremely basic:

  • support for viewing Markdown
  • support for GitHub-flavored Markdown (namely checkboxes that you can interact with)
  • avoiding the urge to write something myself the week before Evolve
  • ideally with split-screen support on an iPad

If you saw my talk at Evolve you might have noticed my sticker-covered laptop, but next to it you can see my iPad assistant:

Speaking at Evolve

1Writer

After trying a bunch of different options that didn't quite scratch my itch, including some web-based, my colleague Chris Krycho recommended 1Writer which ended up being perfect for my needs. It also has nice writing and editing support, but I won't really go into that since I didn't actually need that for this use case.

1Writer has built-in Dropbox support, which meant that it could connect to my account that was already being used to store my presentation and notes and load it directly from there. In the rest of this post I'll outline how I set up my flow and used 1Writer to organize my talk's flow and significantly ease my anxiety over missing something.

Create Copy of Base Notes

As I was writing my notes I would store them in a file named script-base.md in Dropbox. This would serve as the starting point for any run through the talk, be it a practice run or the real thing. 1Writer makes it was to create a duplicate of a document, so each preparation round for a run of the talk would begin by duplicating the base script and giving it an appropriate name:

Creating a duplicate

Checking Off Items

The first section of my script was a list of things that need to be done prior to stepping on stage and delivering the talk. This includes everything from bumping up font sizes, logging into services, turning on Do Not Disturb, etc. Nothing is too simple to leave off the list here, so it's a great way to have a master list of everything you could forget in the moment. As I completed each step I would check it off in the document:

Checking off items

Since this is working off a fresh copy of the script there's no need to worry about having to uncheck everything to start over.

Including Steps for Demos

My goal was to be totally driven by memory for my demos and not have to refer to my assistant, but since it was there anyway it would have been silly to not include details of the entire thing in there. Since I was working in Markdown, it meant that I could easily annotate code that I was planning to write from scratch, which could serve as a reminder of what I needed to write in case of temporary memory loss:

Coding checklist items

Unlike the earlier section where I'd check off items as I completed them, that was not a goal of mine for the demo section since that would break the flow of the presentation. In my case these checkboxes could just as easily have been bullets, but I left them as checkboxes since it was occasionally useful during preparation when working on timing.

Split Screen

One of the nice-to-haves I was after was support for running in split-screen mode on my iPad. The main reason for this was that it allowed me to run 1Writer side by side with the built-in iOS timer app, which was awesome for being able to have something I could look to and see where I was at without having to break my flow and look somewhere else.

Split screen with timer

Miscellaneous

1Writer also offered a lot of nice options for theming, fonts, text size, etc, which made it easy to tailor the view to just how I wanted it. I should also note that 1Writer is not a free app. It's currently just $4.99 in the iTunes app store though, which was an absolute bargain for the value I got out of it. I suspect that I'll be taking this approach more often for future talks.

May 10, 2016 5:54 GMT

Reactive

Many web programmers, especially Angular programmers are turning their attention to RECoverReactive programming.  While I don’t know of any books on ReactiveJS (yet) I can shamelessly mention that I do have a book on Reactive Extensions and LINQ.

 

NB: This book is short (which I think is a good thing) and pricey, but will give you a solid introduction and more to both topics.

My co-author, Paul Betts, is not only a genius, but he is one of the foremost experts on Reactive.

Here is the TOC:

RETOC

May 10, 2016 10:54 GMT

A very small pub/sub solution for Xamarin Forms

I've created a small project called TinyPubSub that only does one thing at the moment. It's made especially for use with MVVM and Xamarin Forms.

DISCLAIMER: This is a very early version of the library.

Short version: 



Long version:


I'm a big fan of vanilla MVVM. That means that I don't like to add other frameworks on top of what's already possible to achieve using only Xamarin Forms. 

A very common scenario is that I have a main page that are supposed to display some kind of data, let's say a list of ducks. I then navigate down a couple of pages in the app and find a page where I can add a duck. This should then update the first page. I could do this update in the OnAppearing event of the page but that breaks two nice rules of mine:
  1. The page should not start to load data when it is resurfaced. It should have already done that.
  2. The view is starting to handle logic. We don't want that.
So I created a small (tiny one might call it) library that solves this in the most simple way I can think of. It also handles dereferencing in a nice way. As long as you don't use Navigation.PopToRoot(); for the time being.

The features being:
  1. Simple usage
  2. Automatic un-subscription


The code

This is the structure of the project in the sample supplied with the source code (available at github).

Initialization

To initialize TinyPubSubs automatic dereference magic, just add this code to each NavigationPage you create. I'm looking at creating a forms library that adds an Init-method instead. But for now, do this.

        public App ()
        {
            // The root page of your application
            var navPage = new NavigationPage(new MainView());

            navPage.Popped += (object sender, NavigationEventArgs e) => TinyPubSub.Unsubscribe(e.Page.BindingContext);
            
            MainPage = navPage;
        }

Usage in the ViewModels

In the constructor of the ViewModels, add subscriptions like this

        public MainViewModel ()
        {
            TinyPubSub.Subscribe (this, "update-ducks", () => 
                { 
                     // Get data and update the GUI
                });    
        }

The "update-ducks" string is just a arbitrary name and you can select what ever you want. Note that I don't pass any data (yet), but that might be the next step in destroying this library by bloating it.

Publish events

In another ViewModel we then decide to add a duck. 

        public ICommand AddDuck
        {
            get {
                return new Command (async () => {
                    // Do logic and add stuff

                    // Publish an event
                    TinyPubSub.Publish ("update-ducks");
                    await Navigation.PopAsync();
                });
            }
        }

This will fire the actions (synchronous at the moment) and then pop this view. The cool part is that when we pop the view, the subscriptions will be unsubscribed (remember the code in the beginning of the post) and the memory will be cleaned up.

Summary

This is a simple way to solve a common problem. There is a built in Messaging Center in Xamarin Forms that I personally find a bit messy to use.

Future features might be async actions and passing of simple data.

May 09, 2016 1:00 GMT

NuGet gold nuggets &amp;#8211; packages which are in my almost every Xamarin project

While Xamarin delivers a nice set of controls and functionalities with Xamarin.Forms, there is always room for improvement.

Luckily there is a very active and alive community behind Xamarin which can provide you with all the necessary plugins. Underneath you will find a list of the ones I use in almost everyone of my projects in varying combinations.

If you have any recommendations which I have missed please let me know!

Xamarin.Plugins.Settings

This plugin by James Montemagno provides corss platform (user) settings. It supports simple types (strings, integers, booleans, etc.) and is available for both shared projects and PCL projects. If using a PCL, you need to install the NuGet package on both yourPCL project as well as the client projects.

Setup is super simple and is described on the homepage as well as a text file which comes with the NuGet.

Available for iOS, Android and Windows.

GitHub & NuGet

Xamarin.Plugins.Connectivity

Another plugin by James (see above), basically anything he touches is something you want to have or take a look at so keep that in mind.

This plugin provides you with everything you need regarding network connectivity. You can check if you have a (internet) connection, ping a certain server and also it provides you with events if something in the network changes. If using a PCL, you need to install the NuGet package on both yourPCL project as well as the client projects.

Available for iOS, Android and Windows.

GitHub & NuGet

FreshMvvm

Lightweight, easy to use MVVM framework which perfectly complements the MVVM capabilities Xamarin.Forms already has. It supports ViewModel to ViewModel navigation, automatically wires BindingContext and page events, provides a simple IoC container with constructor injection, and more!

FreshMvvm has been created by Michael Ridland, a Xamarin consultant and MVP which is very open to suggestion.

Available for iOS, Android and Windows.

GitHub & NuGet

FreshEssentials

Again by Michael, he also brings you the essentials NuGet package. This contains everything you’ve probably done by hand in most of your Xamarin.Forms apps.
It provides you with a BindablePicker, InverseBooleanConverter and SegmentedButton for iOS amongst others. It will probably grow larger over time.

GitHub & NuGet

PropertyChanged.Fody

INotifyPropertyChanged made easy! No longer implement that same interface in all of your classes and repeat the same steps over and over.
With this package you can just add the propertychanged functionality with a class attribute! Also you can attribute your properties to get some more control over when the propertychanged gets fired. It will all be done for you at compile time!

This isn’t limited to Xamarin by the way, but comes in very handy!

GitHub & NuGet

FFImageLoading

A library which helps you with easily scaling down images, caching them, applying transformations, etc.

Available for iOS, Android and Windows.

GitHub & NuGet

ACR.UserDialogs

Based on popular libraries on Android, iOS and Windows this library provides you with an easy wat to show alerts, loading indicators, ActionSheets, messagebars and everything else you can come up with!

It is very easy to use, don’t forget to put the initialiser for your Android project!

Available for iOS, Android and UWP. Partial Windows 8/8.1 implementation which you can of course add yourself by a pull request.

GitHub & NuGet

Refit

If you have already created some apps you’re probably used to calling REST API’s. Although all of them are different, the way you call them and interact with them is very similair, which makes you type out the same functionality multple times. No more! With this library your REST calling class is generated automagically!

Just define an interface with all the methods you need, attribute them with the endpoint names and HTTP verbs and you are ready to go!

Not just available for iOS, Android and Windows, but also Xamarin.Mac and .net 4.5 desktop apps! Awesome!

GitHub & NuGet

Polly

Polly is a library which takes exception handling to a new level! You can easily retry for multiple times, wait a bit before you retry, defines policies and all of this in a fluent syntax! This comes in rather handy if you’re working with not always stable connections and you might want to retry a couple of times before handing the error to your user.

Also this one is available for all app platforms as well as on desktops.

GitHub & NuGet

There are probably a lot more I might of missed and/or don’t know of yet. Please let me know if you have any additions which I might include in a next post and make all of our lives a bit easier!

May 08, 2016 10:31 GMT

Back to the future!

For about 15 years I specialized in Web programming of one sort or another (writing half a dozen books and, more recently, half a dozen Pluralsight courses) and for the past two years, I’ve added Xamarin.

These tEvolvewo interests came together this month.  I had the privilege of presenting at Evolve (the largest mobile conference) and then I had the pleasure of attending NG-Conf, the largest conference on Angular.

At Evolve there were a number of announcements about Xamarin, and I had a good time talking with friends (the hallway conversations are always the most valuable part of any conference)

The schedule and speakers were great, and the excitement and energy in the Keynotes was terrific.

The very next week, I attended NG-Conf.  I started out with a full-day workshop presented by two of my friends, John Papa and Dan Wahlin (see photo below).

NG Conf  is interesting because Wednesday and Friday are single-track, with each presentation lasting 20 minutes.  This causes (forces?) the presenters to get to the point and not to waste any time at all.  
IMG_0461

Angular 2 is a very exciting development in front-end Web technology.  It is quite different from, and in my opinion a significant improvement over Angular 1.

Stay tuned for more details on Angular 2 as it settles down and nears version 1.0.

 

 

 

May 06, 2016 1:30 GMT

Weekly Xamarin Newsletter Issue #91

Hello Weekly Xamarin newsletter subscriber. I (adam) am stepping down as this newsletters scribe / writer / producer. Not to worry, everything is OK with me. The new scribe will hopefully start up where I left off and issue #92 will be in your inbox next Friday. I will be transferring everything (Domain, Email, Twitter, MailChimp) to him soon.

Thank you for letting me into your inbox for the last 91 weeks. Writing the newsletter has been a fantastic experience and to be honest, it’s the longest, continuous thing I’ve done in tech. With my work taking me away from the mobile space, I thought it best to have a scribe that “uses it in anger” to write the newsletter. I’ll let the new scribe introduce himself in a future newsletter. You are in good hands.

Thank you, the Scribe (adam).

Announcing HttpClientDiagnostics
Geoffrey Huntley adds diagnostics tracing and logging to Microsoft.Net.HttpClient.

Xamarin.Forms XAML Previewer Design Time Data
James Montemagno shows you design time data. Reminds me of Silverlight.

Enabling Multitouch using CocosSharp
Johan Karlsson gets all touchy with the CCGameView.

Snppts.io: share your amazing Xamarin.Forms designs!
Gerald Versluis hopes you’ll use and contribute to snppts.io.

Xamarin Studio – Visual Studio Goodness on Mac
Mayur Tendulkar is loving the updates on Xamarin Studio.

SQLite with Xamarin Forms Step by Step guide
Srkrathore adds SQLite to his Xamarin.Forms apps.

Xamarin Evolve 2016 App Development Retrospective
James Montemagno goes over what went right and wrong with the Evolve 2016 App.

The post Weekly Xamarin Newsletter Issue #91 appeared first on Syntax is my UI.

May 03, 2016 6:41 GMT

Enabling multitouch using CocosSharp

It's been a long time since my last blog post due to personal and professional reasons. Anyhow, now I'm planning to get back in the saddle and start blogging on a regular basis again. Also, this happens to be blog post number 100. Yay!

Short version


To enable multitouch in CocosSharp (Forms version) you must create a custom renderer to set the MultipleTouchEnabled on the CCGameView (platform specific code) and then you must inherit from the CocosSharpView in order to make the registration of the custom renderer work. Code in the bottom of the post.

Long version


I've started a little secret project of my own that required two things:

  1. A simple framework for drawing stuff
  2. A simple input scheme for multitouch

So I checked out the available frameworks out there for Xamarin (especially for Xamarin Forms) and I decided to give CocosSharp a run for its money. I've done some small CocosSharp projects before and it fits my needs for the prototyping of this app.

I'm using the Forms version of CocosSharp since I'm a big Xamarin Forms fan.

The issue


One of the first things I noticed was that the multitouch simply didn't work as I expected. No matter what properties I set there was no multitouch going on. After some google-fu I found out that you have to set the MultipleTouchEnabled to true on the CCGameView instance. Well, the CCGameView is platform specific and there is no exposure of this property in the platform agnostic CocosSharpView that you use in the forms project.

Custom renderer to the rescue


Well, that's a simple fix I figured. Simply create a custom renderer and set the property directly.

    protected override void OnElementChanged (ElementChangedEventArgs<CocosSharpView> e)
    {
        base.OnElementChanged (e);

        if (Control != null) {
            Control.MultipleTouchEnabled = true;
        }
    }

That didn't work. In fact, the method is never called. (Yes, I registered the renderer! :) ).

Create a custom control (the work around)


So the simple work around for this was to create a custom control.

    public class MyCocosSharpView : CocosSharpView 
    {
    }

And then use MyCocosSharpView instead of CocosSharpView. I'm not sure why it behaves this way, but its got to have something to do with the registration of the custom renderer. Hopefully I'll get some time to drill down in the source code and find out why.

What I would like


The MultpleTouchEnabled property should be visible from the CocosSharpView class. That is at least what I'll suggest to the CocosSharp team.

The code


These are the interesting parts of the code. 



May 02, 2016 1:00 GMT

Snppts.io: share your amazing Xamarin.Forms designs!

For the last few weeks me and my good friend Steven have been busy creating a platform for sharing your beautiful custom UIs in Xamarin Forms.
While Forms is ideal for simple, data-entry apps, it is also possible to create awesome UIs with just code and XAML, but also with the use of custom renderers.
And because Forms uses those techniques it is very easy to lift those designs out of your app and share them!

We noticed there are a lot of cool interfaces out there so we wanted to offer a exchange for developers, by developers to share our preciously styled user interfaces.
The format isn’t very strict; you can submit your design, supply the GitHub repository that has the necessary code/XAML (and maybe an example app, or just reference your live app using this design) and that’s it! So very accessible and easy to share for everyone.

While there are only a few snippets online right now we hope you will participate in our awesome new platform and it will grow very fast!

If there are any errors, or you want to request features we’ve missed – and we probably did because we’re still developing.. – just drop us a message by mail (hello@snppts.io) or Twitter (@snpptsio).

Quickly go over to snppts.io and go look for yourself!

We hope you will love it!

May 01, 2016 2:16 GMT

Xamarin Studio – Visual Studio Goodness on Mac

During Evolve 2016, Xamarin released Xamarin Studio (XS) for Mac as a Release Candidate. This release of XS provides more goodness like Visual Studio on Mac. Let’s see some of the features that are available in this release.

1. Dark Theme
For people like me, who work late at night, this is a boon. You can easily switch the theme and get ‘Dark Theme’ for your IDE. You can change the theme by going to
Xamarin Studio > Preferences > Environment > Visual Styles

XS-Dark-ThemeYou’ll need to restart the IDE to see the effects.

2. New Icons and Graphics
You can see lot of new improvements in terms of graphics and icons when you open a project.
XS-Icons-Graphics

3. Roslyn Support with IntelliSense / Code Completion
XS is rewritten to support Roslyn. It allows code- refactoring and better IntelliSense in IDE. This is like a ReSharper for me :)

XS-IntelliSense

4. Xamarin.Form Previewer
Xamarin.Forms Previewer will allow you to see your XAML design right next to it. It is live, so changes in XAML can reflect in UI. You can see the UI results for iOS and Android for both Phone and Tablet mode in both Portrait or Landscape mode. To see the preview, click on ‘Preview’ button on top right corner.
XS-Forms-Preview
Note: You’ll need Xamarin.Forms v2.3x Pre NuGet package to get this working.

5. Better NuGet Support
You could always add specific version of NuGet package in XS by appending ver in query string while on ‘Add Packages’ window. However, now it has became more easier as XS provides a drop-down for version selector. Small feature, but very helpful.
XS-Nuget-Versions

These are the top 5 features which I can think about when it comes to new Xamarin Studio release. There are many more and you can read about them in release documentation. I’m sure, you’ll enjoy this release.

Namaste,
Mayur Tendulkar