Wallace B. (Wally) McClure: Drill Into Problems with Xamarin Insights

Url: https://visualstudiomagazine.com/articles/2016/03/01/xamarin-insights.aspx

You’ve completed the initial version of your mobile app. You’ve deployed it. And now, you’ve started to get reports of exceptions in your app. It doesn’t happen all of the time, and it doesn’t happen to all users, only some of them. What’s worse is that the errors aren’t often repeatable. For some reason, the issues some users are having can’t be repeated in your office. You drive around and try to repeat the errors but you can’t, so you wonder if it’s is a location issue. Perhaps it’s a cell signal issue. Perhaps the issue is the version of the OS the user is running. You’re stuck and you don’t know what’s causing the errors. You need more information in order to solve the problem, so where do you turn? Xamarin has released a product just for this situation. It’s called Xamarin Insights.


Xamarin: Performing Background Data Refresh for Android

Data is a crucial component of any app, which is why perfecting how your application interacts with data is so important. There are many techniques for improving interactions with remote data, such as request prioritization, speculative requests, and caching. These are certainly techniques to be explored and used, but what if your data was there […]

The post Performing Background Data Refresh for Android appeared first on Xamarin Blog.


Marcos Cobeña Morián: Monkey.Tap with Wave Engine

A few weeks ago Xamarin published on their blog a bunch of entries with a nice step-by-step guide to create Monkey.Tap with MonoGame. We believe Wave Engine can offer some advantages when creating games, such like its component-based architecture, or the new cross-platform Wave Visual Editor, among other ones; so we’ve reproduced Monkey.Tap with Wave… Continue reading Monkey.Tap with Wave Engine

Xamarin: Xamarin Evolve 2016 Speaker Spotlight: Jason Smith

This is the third post in our Xamarin Evolve 2016 “Speaker Spotlight” series, helping you get to know a little bit more about some of the amazing speakers who will be contributing at this year’s conference. Today we’re highlighting Xamarin’s own Jason Smith, who has been working on UI and front-end development for the past […]

The post Xamarin Evolve 2016 Speaker Spotlight: Jason Smith appeared first on Xamarin Blog.


Tomasz Cielecki: Using RESX files in PCL for Xamarin and Windows projects

I’ve been working on a project which is targeted for Xamarin.Android, Xamarin.iOS and Windows 8.1 (non-Silverlight). They are all sharing the same PCL projects for ViewModels, Services etc. Hence, I thought this was an ideal place to chuck in application strings. Don’t get me wrong, it still is! However, there are some things you need to know in order to get it to work nicely with the Windows 8.1 project.

Windows 8 introduced new RESW files, which structurally are similar to RESX files. However, instead of needing to have all sorts of helpers etc. to bind localized text strings and now dimensions etc. to properties of FrameworkElements, that is now done by convention. Which is really neat. However, this is of course only for Windows 8.
How this looks in practice is that your key for some resource could be something like: Welcome.Text and the value could be something like Hello, World!
In your XAML file you could then have something like <TextBlock x:Uid=”Welcome” Text=”Design Time Text” /> and then the Text property would automatically be set to the one in the RESW file. Neat!

Now all this RESW stuff is cool and all. However, if you are either too lazy to migrate to RESW or if you want to use RESX files because they work nicely with Xamarin projects then it is not all that nice in the Windows 8 world.

In Debug using the RESX approach, it switched automagically to the correct language. However, as many other posts around the Internet described, this was not the case on a device when having created a Store package. It would always default to the neutral or default language.

Several sources say this blog post is the solution to the problem in my case nothing actually happened. It describes how to use your own implementation of ResourceManager and having a break-point in the GetString method I saw the CultureInfo always was null. However, the Default one was actually correct. Nevertheless the incorrect language was taken from my RESX files when deploying a Store package.

After having spent way too much time on figuring this issue out I fell over this blog post, which points out a key to still be able to use RESX files in a Windows 8.1 project and Xamarin projects at the same time with it being shared in a PCL.

The steps are quite simple.

  1. In the PCL where you have your RESX file(s) add the following to the csproj file: <SupportedCultures></SupportedCultures> this should simply contain the language codes semi-colon separated like so: <SupportedCultures>en;da;de</SupportedCultures>
  2. In your Windows 8.1 project. Create a strings folder with each of the supported language codes as subfolders.
  3. Create a RESW file in each of those language code subfolders.
The result should look something like
That is it. Now your Windows 8.1 project should be able to pick up all the languages you have specified and you can get the correct strings from your RESX files.
Here is how I use it.
In my PCL I have a small helper for Windows 8.1 which looks like:
I have registered that helper in my App.xaml file like so:

Then I can use it like this in my Windows 8.1 app XAML pages and templates:

Given that Welcome is a key in the RESX files.

On iOS I create my views in C# code pretty much by hand. Hence I simply use the RESX files directly. So if we say my RESX file is called ApplicationStrings.resx then usage looks like:

On Android I use RESX localization plugin for MvvmCross, where Stefan Schoeb has a very nice description on how to use it. I don’t use it for iOS since it is just easier to directly get the strings. Less code