Tuesday, March 6, 2012

Windows Phone - Are they mad?

Today I came across my first real Windows Phone WTF moment. I needed to show a long text and that should be a very trivial matter on almost any platform. Is it non-trivial on Windows Phone? No.

Imagine this: No controls (buttons, images, textboxes etc) can have a width or height larger than 2048 pixels. This has to do with the hardware rendering and texture sizes in some way and it completely prevents you from displaying a long text (such as the very verbose "Terms & Conditions" text I needed to show)... how on earth can such a limitation exist on a modern device and platform such as Windows Phone?

So what's the workaround? Well, from what I figured the best way is to split the text into several texts, each less than 2000 pixels high. Luckily there's a class that Alex Yakhin has made available on an MSDN blog. The class comes packaged into a DLL which means that you can't really modify it that much. Another option would be to display the text in a web control, but that is cumbersome if it's local data from a text resource (you need to write it to a file in IsolatedFileStorage first).

In my case neither of the solutions work well. I wanted a page with a title, a long text and a button below the text and all of the page should scroll. Using Alex Yahkin's class the title would not move and neither would the button. The same goes for the web control...

1 comment: