EziData Solutions

Web, NET and SQL Server

New size options for HubTiles

One of the main visual changes to the start screen in Windows Phone 7.8 and 8 is that it now supports three sizes of live tiles. The default (medium) tile is now larger and gone is the black strip to the right that used to be home to an arrow that took you to the app screen. 

This milestone seemed like a good time to revisit the HubTile control from the Windows Phone Toolkit to see if it could support these new formats. The early versions on the HubTile is was a painful process to choose the size of the tile, having to resort to copying and modifying the XAML elements and animations, as discussed in the post. 

Thankfully, since the September 2012 release of the Windows Phone Toolkit, the HubTile control now comes with a Size property that allows you to select from four sizes, Default, Small, Medium and Large. A look at the source code for this release reveals the size of each of these tiles.

switch (hubTile.Size) 
{ 
    case TileSize.Default: 
        hubTile.Width = 173; 
        hubTile.Height = 173; 
        break; 
  
    case TileSize.Small: 
        hubTile.Width = 99; 
        hubTile.Height = 99; 
        break; 
  
    case TileSize.Medium: 
        hubTile.Width = 210; 
        hubTile.Height = 210; 
        break; 
  
    case TileSize.Large: 
        hubTile.Width = 432; 
        hubTile.Height = 210; 
        break; 
}

Using these new sizes with the data bound HubTile example we used in another post is simple. The easiest option is to specify the Size property in the ItemTemplate.

<ListBox Grid.Row="0" Name="AvatarListView">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <toolkit:WrapPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <toolkit:HubTile 
		Margin="12,12,0,0" 
		Title="{Binding Title}"
		Message="{Binding Message}"
		Source="{Binding ImageUri}"
                Size="Medium"/>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

Of course, you can also bind the Size property to property on your underlying data source. To do this, add a TileSize property to the HubTileItem class and modify the HubTile control XAML as below.

public class HubTileItem
{
    public string Title { getset; }
    public string Message { getset; }
    public Uri ImageUri { getset; }
    public TileSize TileSize {getset;}
}

<toolkit:HubTile 
	Margin="12,12,0,0" 
	Title="{Binding Title}"
	Message="{Binding Message}"
	Source="{Binding ImageUri}"
   	Size="{Binding TileSize}"/>

Posted: Feb 05 2012, 21:53 by CameronM | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5