C#
Optimize memory usage in Xamarin apps
This post has been translated to Russian by Denis Gordin . You can read the Russian version on the Russian website TechMedia . Thanks, Denis! Xamarin is amazing in how it allows .NET developers to write apps for Android, iOS, MacOS… in C#. But that amazing capability comes with a prize and even the most simple apps can suffer from high memory usage. Let’s find out what happens and what we can do about it. The majority of my examples are based on Xamarin.Android, but you’ll quickly notice how this also applies to Xamarin.iOS.
A few common issues with .csproj files in Xamarin apps
Usually you don’t need to manually edit .csproj files for your apps and most developers don’t even know what’s going on inside this file. However, sometimes you might run into issues related to this file where Visual/Xamarin Studio can’t help you. The case of the missing references At my current client our solution consists of more than 10 projects:
Creating a Xamarin.iOS binding project for dummies
What you need Experience with Xamarin.iOS Xamarin Studio for Mac An empty binding project (just create a new project in Xamarin Studio) A very short intro to Objective-C for C# developers Oh god, Obj-C, the most incomprehensible programming language in the app dev world. You simply can’t create an iOS binding project without some very basic knowledge of Obj-C. So here goes, an intro to Obj-C for C# developers.
Fix common binding errors with MVVM Light on Xamarin
There isn’t much documentation available for MVVM Light when it comes to Xamarin.Android and Xamarin.iOS. There are several overloads for the SetBinding method and using the wrong overload causes TargetInvocationException or TargetException like this one . It’s also possible that your bindings don’t update anymore after you set one binding using an incorrect syntax.
Dependency injection with Autofac and MVVM Light in Xamarin
You gotta have MVVM A developer and his tools are inseparable. We all like SOLID and every (.NET) developer has his or her favourite dependency injection tool. There is a lot to choose from. I like Autofac because of the way it handles modules, the lifetime of a type and how it registers types.
Queue for MessageDialog in Windows RT
When I write Windows Store applications, I use MessageDialog a lot. It’s the easiest way to show a quick informative pop-up message or a question to the user. However, when you tend to use this quite often, you’ll probably run into a problem. The Windows Runtime framework doesn’t allow you to stack MessageDialogs, queue them etc. So if you need to display one, you’ll have to make sure that no other MessageDialog is already open. Checking if there is an open MessageDialog is not that easy unless you keep references to all the MessageDialogs you create. There are a few cases in which this would be annoying.