Using ngrok to debug your API’s from your Xamarin Forms App

Sometimes, you want to see what is going on when your nice shiny new App is supposed to connect to your awesome API and get some data from it/to it. Unfortunately – your App will (mostly) not connect to your API when it’s running on localhost. Android provides a nice little get around by using the DNS 10.0.2.2 – but this isn’t much use from an iOS device. And I find I really prefer to test from my development phones, rather than an emulator.

Recently I came across an amazing tool to help me out with this – ngrok. This creates an externally accessible URL poiting to your localhost. Even better – there is a Visual Studio extension that will start a tunnel for each application within your solution.

Continue reading

Recognising when an item updates within an Observable[Range]Collection

I’m currently working on an app that needs to show the pictures and videos held on the user’s device for them to select from. I came across this great post by @XamBoy that I have used to get the media and save it in an ObservableRangeCollection.

NB an ObservableRangeCollection is an object that inherits from ObservableCollection, created by James Montemagno and available through his MvvmHelpers NuGet. Everything described below can be changed to extend just the ObservableCollection instead.

Continue reading

Xamarin Forms Converters

I love Converters in Xamarin Forms. They give you a nice, easy way to display something through your XAML based on a value in your binding data. And they are so easy to set up.

All converters inherit from IValueConverter and must implement two methods: Convert and ConvertBack.

public class MyConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// do something to get a new value
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
// and change it back if you want to
}
}
view raw MyConverter.cs hosted with ❤ by GitHub
Continue reading

Mimicking a modal in Xamarin.Forms

Control Templates are a versatile element in Xamarin Forms. A good description can be found in the Microsoft documentation. Recently I wanted to try and save some screen space on an app where I have some help text that, especially on smaller phones, takes up more room than I would like. Using a Control Template to add functionality that replicates a modal window on a website was a nice way to ensure that the help text was still available, but only if the user wanted/needed to see it.

Here’s how we can do this.

Continue reading

Open cmder from Visual Studio

This blog has been inspired by Rick Strahl’s article Tip: Create a Visual Studio Menu option to Open a Command Window. Rick details how to set up Visual Studio to allow you to open Console2 from a keyboard shortcut within Visual Studio.

This is great, but I prefer cmder myself. The setup is very similar to the instructions provided by Rick, the only real difference being the argument to start in the current directory.

Continue reading