Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are on the right track. <code>WrapPanel</code> is the way to go :)</p> <p>To make each block more interesting, you can take a look at the <a href="http://www.windowsphonegeek.com/articles/Windows-Phone-HubTile-in-depth-Part1-key-concepts-and-API" rel="noreferrer">HubTile</a> control from the latest <a href="http://phone.codeplex.com/" rel="noreferrer">windows phone toolkit</a>. Whatever controls/panels you are using, just remember the size should be 173*173.</p> <p><strong>Use a ListBox</strong></p> <p>In one of my projects I created a <code>ListBox</code> that does all this. The reason that I use a <code>ListBox</code> is because <code>ListBox</code> has a <code>SelectedItem</code> propery which tells me which tile is tapped by the user. Also another reason is <code>ListBoxItems</code> can receive the nice tilt effect.</p> <p>Baiscally you just need to create a tile-like <code>ListBoxItem</code> style and apply it to the <code>ListBox</code>'s <code>ItemContainerStyle</code>, also you need to set the <code>ListBox</code>'s <code>ItemsPanel</code> to be a <code>WrapPanel</code>.</p> <p><strong>How it looks</strong></p> <p><img src="https://i.stack.imgur.com/IfjYK.png" alt="enter image description here"></p> <p><strong>The ListBoxItem Style</strong></p> <pre><code>&lt;Style x:Key="TileListBoxItemStyle" TargetType="ListBoxItem"&gt; &lt;Setter Property="HorizontalContentAlignment" Value="Stretch"/&gt; &lt;Setter Property="VerticalContentAlignment" Value="Stretch"/&gt; &lt;Setter Property="Padding" Value="0"/&gt; &lt;Setter Property="FontSize" Value="64"/&gt; &lt;Setter Property="Margin" Value="12,12,0,0"/&gt; &lt;Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/&gt; &lt;Setter Property="Foreground" Value="White"/&gt; &lt;Setter Property="Width" Value="173"/&gt; &lt;Setter Property="Height" Value="173"/&gt; &lt;Setter Property="HorizontalAlignment" Value="Left"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="ListBoxItem"&gt; &lt;Grid&gt; &lt;Rectangle Fill="{TemplateBinding Background}"/&gt; &lt;ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p><strong>The ListBox</strong></p> <pre><code> &lt;!-- set its ItemContainerStyle which is the style for each ListBoxItem --&gt; &lt;ListBox ItemContainerStyle="{StaticResource TileListBoxItemStyle}"&gt; &lt;!-- set its ItemsPanel to be a WrapPanel --&gt; &lt;ListBox.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;toolkit:WrapPanel /&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ListBox.ItemsPanel&gt; &lt;ListBoxItem&gt; &lt;Grid&gt; &lt;TextBlock Text="Messages" /&gt; &lt;StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"&gt; &lt;Path Data="M1.4901163E-05,9.8579922 L50.000015,46.316994 L100.00002,9.8579922 L100.00002,62.499992 L1.4901163E-05,62.499992 z M0,0 L100,0 L50,36.458 z" Fill="White" Height="38.125" Stretch="Fill" UseLayoutRounding="False" Width="61" d:IsLocked="True" /&gt; &lt;TextBlock Text="12" Margin="4,0,0,8" /&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/ListBoxItem&gt; &lt;ListBoxItem/&gt; &lt;ListBoxItem/&gt; &lt;ListBoxItem/&gt; &lt;toolkit:HubTile Title="Me ☺" Message="..." Notification="new messages!" Source="xxx.jpg" Margin="12,12,0,0" /&gt; &lt;/ListBox&gt; </code></pre> <p>You can see the last item is actually a <code>HubTile</code>.</p> <p>Hope ths helps! :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload