Windows Phone UI Tip – Empty List Header Style

I’ve already talked about creating a so-called “empty list box template” for situations when you have no items and an empty screen area might confuse users. You could fake it by adding a little TextBlock control that would be shown when you have an empty ListBox control to tell the user that (s)he would normally have a list of items there.

To do that, I blogged about two different techniques: ListBox empty template – using visual states (part 1) and ListBox empty template – using control templates and behaviors (part 2).

One thing I haven’t talked about before is what should that text look like. In my opinion, unless you are completely reinventing your UI, you should strive for consistency. The best way to do that is mimicking the built-in apps. You already have such style in the stock applications: e.g. if you open Marketplace and search for some non-existing application, you will get the message that there are no such applications as you can see below. If you want to use exactly that style, you can use a predefined style called EmptyListHeaderStyle:

<TextBlock Style="{StaticResource EmptyListHeaderStyle}"
           Text="Some items should appear here..." />
Simple style for the "no results found" text

Simple style for the “no results found” text

If you are still targeting Windows Phone 7, you won’t be able to use that style because it was introduced in Windows Phone 8. But if you still want to use it, copy/paste the following style definitions in your favorite place for styles:

<System:Double x:Key="EmptyListHeaderFontSize">32</System:Double>

<Style x:Key="EmptyListHeaderStyle" TargetType="TextBlock" BasedOn="{StaticResource PhoneTextBlockBase}">
  <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiLight}"/>
  <Setter Property="FontSize" Value="{StaticResource EmptyListHeaderFontSize}"/>
  <Setter Property="Foreground" Value="{StaticResource PhoneSubtleBrush}"/>
</Style>

UPDATE: Please not that Windows Phone 7 does not have PhoneTextMidContrastColor, but PhoneSubtleBrush is close enough. It matches the dark theme version exactly, but is slightly different in the light theme.

Last updated by at .