Metro Nuggets

Bitesized tidbits for building Modern (Metro) apps.

Tag Archives: Developer

ListBox to LongListSelector in Windows Phone 8

If you’re moving a project from Windows Phone 7 to Windows Phone 8 and you use ListBoxes in your app, you can keep them in there with no real problems. However, it’s not recommended to keep using them, instead use the LongListSelector instead. If you’re familiar with the LongListSelector from the Windows Phone Toolkit, then you’ll find the new native LongListSelector a very different beast and you probably wouldn’t think to use it because you know what it was previously only really used for. Previously you would only really use the LongListSelector if you were after a people hub or application list style grouping, but the new native version has been tweaked and improved upon and had massive performance enhancements. You can also just use it as a straight, flat ListBox, complete with all the performance enhancements it brings.

Making the change from ListBox to LongListSelector is actually very simple, just change your xaml to use the LongListSelector instead of the ListBox. It’s as simple as that. When you then run your app, it will already be a flat ListBox as you were before, but with those mentioned performance enhancements.

Before:

            <ListBox x:Name="LLS">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}"
                                   Style="{StaticResource PhoneTextLargeStyle}" />
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>

After:

            <phone:LongListSelector x:Name="LLS">
                <phone:LongListSelector.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding}"
                                   Style="{StaticResource PhoneTextLargeStyle}" />
                    </DataTemplate>
                </phone:LongListSelector.ItemTemplate>
            </phone:LongListSelector>

It’s as simple as that.

Stay tuned for more on the new LongListSelector.

SL

Small Primary Live Tiles Not Updating in Windows Phone 8

In an update to one of my Windows Phone apps, I decided to leverage the new size tiles that we have been afforded in WP8. However, I ran into a problem whereby the tile data I wanted to be displayed wasn’t showing on the primary tile, but was on the secondary; the primary tile showing just a small version of the app icon:

image

Secondary tile on the left, primary on the right. I knew the data to be displayed was being created, because if I changed the size of the tile, it was showing the correct image. So how to sort it?

Read more of this post

Binding To Anonymous Types

I was working on an app recently where an xml datasource was pulled in and I decided to use linq to parse the data to an anonymous types. The plan was to then bind that data to the listbox in my UI. The data got parsed correctly and I could see my anonymous type, but my UI was simply not being updated. So what was wrong?

Read more of this post

Tango (7.1.1): Detecting Devices With 256MB

Windows Phone update codenamed Tango is coming soon and with it comes devices that have a lower amount of memory in them than the usual 512mb, specifically 256mb. Your app needs to take into account whether it should be able to run on phones with 256mb of RAM and is discussed pretty well on MSDN at http://msdn.microsoft.com/en-us/library/hh855081(VS.92).aspx. So is there a quick way in your app of seeing whether the device your app is running on is 256 or 512mb? Yes, and is touched on in that MSDN link, I decided to just extend the code they give to give a quick and easy property that you can have in your app/viewmodel.

Read more of this post

PhoneFlipMenu Control for Windows Phone [UPDATED]

UPDATE: This control is now part of the coding4fun toolkit for Windows Phone. It’s usage is the same, but it’s been renamed to the AppBarPrompt. Any future updates will done to that, and not this version. Sample usage of the new prompt can be seen here.

The Windows Phone Mail app has, when you’re in an email, a respond button which when tapped, brings up three further options, as illustrated below:
Screen Capture (3) Screen Capture (2)

On the left we have the icons on the application bar, tap the respond button (on the left) and you get the options as shown in the picture on the right.

There is, however, no way of doing that in your own apps, so I created this control that does it.

Read more of this post

PRO TIP: Creating A Private Beta? Add Yourself To It!

The AppHub and Marketplace support private betas which as a developer is great, you get to give it to real people who might not necessarily have a developer unlocked (or ChevronWP7 unlocked) device. This is done by you submitting an app to the AppHub in the same way as you would with a normal app, but with one difference, in the first page, you change this option:

image

Once this goes through, you can then give your beta testers a zune link and they can access the app through their phone’s MarketPlace hub. Part of the process of submitting a beta app is providing a list of Windows Live IDs, and these WLIDs are the only ones that have access to the beta.

The acceptance on beta apps is a lot quicker than a normal app as there aren’t as many checks done so you should receive a confirmation within a few hours to say it’s approved and will give you your zune link. Now, here’s the problem: there’s no way of knowing exactly how long it will then take from approval to visibility, especially with how slow the marketplace is at the moment for displaying new apps. There’s no real way of seeing when your app is available in the marketplace to your testers. Or is there?

Read more of this post

Find Your Paid vs Trial Download Figures

So you’ve published your paid for app, you included a trial to hook some people in, great. You look at your download figures in your app list on AppHub and the figures are looking good, great! Roll on that fat royalties cheque from Microsoft. But wait a minute, you included a trial, so could these figures just all be trial downloads? They could be, but it’s not quick to find out, so let me show you.

Read more of this post