我怎么能做这样的事情?(应用程序内的Tiles)Windows手机

Ate*_*eik 18 tiles toolkit silverlight-4.0 windows-phone-7

我很抱歉,如果问题标题不清楚,但我想尝试制作这样的东西,我不知道如果它们是WrapControl中的瓷砖或图像:

在此输入图像描述 在此输入图像描述

我正在考虑使用包装面板制作这样的东西,并将每个块作为堆叠面板.但我不确定这是不是正确的做法.

有没有控制来做这样的事情?

Jus*_* XL 44

你走在正确的轨道上.WrapPanel是走的路:)

为了使每个块更有趣,您可以从最新的Windows Phone工具包中查看HubTile控件.无论您使用哪种控件/面板,只需记住尺寸应为173*173.

使用ListBox

在我的一个项目中,我创建了一个ListBox完成所有这些的项目.我使用a的原因ListBox是因为ListBox有一个SelectedItem告诉我用户点击了哪个磁贴的属性.另一个原因是ListBoxItems可以获得漂亮的倾斜效果.

Baiscally你只需要创建一个瓷砖一样的ListBoxItem风格,并将其应用到ListBoxItemContainerStyle,还需要设置ListBoxItemsPanel是一个WrapPanel.

看起来如何

在此输入图像描述

ListBoxItem样式

<Style x:Key="TileListBoxItemStyle" TargetType="ListBoxItem">
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    <Setter Property="VerticalContentAlignment" Value="Stretch"/>
    <Setter Property="Padding" Value="0"/>
    <Setter Property="FontSize" Value="64"/>
    <Setter Property="Margin" Value="12,12,0,0"/>
    <Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
    <Setter Property="Foreground" Value="White"/>
    <Setter Property="Width" Value="173"/>
    <Setter Property="Height" Value="173"/>
    <Setter Property="HorizontalAlignment" Value="Left"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="ListBoxItem">
                <Grid>
                    <Rectangle Fill="{TemplateBinding Background}"/>
                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)

ListBox

        <!-- set its ItemContainerStyle which is the style for each ListBoxItem -->
        <ListBox ItemContainerStyle="{StaticResource TileListBoxItemStyle}">
            <!-- set its ItemsPanel to be a WrapPanel -->
                <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <toolkit:WrapPanel />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBoxItem>
                <Grid>
                    <TextBlock Text="Messages" />
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
                        <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" />
                        <TextBlock Text="12" Margin="4,0,0,8" />
                    </StackPanel>
                </Grid>
            </ListBoxItem>
            <ListBoxItem/>
            <ListBoxItem/>
            <ListBoxItem/>
            <toolkit:HubTile Title="Me ?" Message="..." Notification="new messages!" Source="xxx.jpg" Margin="12,12,0,0" />
        </ListBox>
Run Code Online (Sandbox Code Playgroud)

你可以看到最后一项实际上是一个HubTile.

希望有所帮助!:)