加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows-phone-7 – 如何做这样的事情? (应用程序内的瓷砖)Wind

发布时间:2020-12-13 21:13:20 所属栏目:Windows 来源:网络整理
导读:对不起,如果问题标题不清楚,但我正在尝试这样做,我不知道如果他们是一个WrapControl中的瓷砖或图像: 我正在考虑用封装面板做这样的事情,每一个块都是堆叠面板。但我不知道这是否是正确的方法。 有没有办法做这样的事情? 你在正确的轨道上。 WrapPanel
对不起,如果问题标题不清楚,但我正在尝试这样做,我不知道如果他们是一个WrapControl中的瓷砖或图像:

我正在考虑用封装面板做这样的事情,每一个块都是堆叠面板。但我不知道这是否是正确的方法。

有没有办法做这样的事情?

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

为了使每个块更有趣,您可以从最新的windows phone toolkit中查看HubTile控件。无论使用哪个控件/面板,只需记住大小应为173 * 173。

使用ListBox

在我的一个项目中,我创建了一个ListBox来完成所有这些。我使用ListBox的原因是因为ListBox有一个SelectedItem属性,它告诉我哪个tile被用户点击。另外一个原因是ListBoxItems可以收到很好的倾斜效果。

Baiscally你只需要创建一个像瓷砖的ListBoxItem样式并将其应用于ListBox的ItemContainerStyle,还需要将ListBox的ItemsPanel设置为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"/>
    <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>

列表框

<!-- 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,8" />
                    </StackPanel>
                </Grid>
            </ListBoxItem>
            <ListBoxItem/>
            <ListBoxItem/>
            <ListBoxItem/>
            <toolkit:HubTile Title="Me ?" Message="..." Notification="new messages!" Source="xxx.jpg" Margin="12,0" />
        </ListBox>

你可以看到最后一个项目其实是一个HubTile。

希望有帮助!

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读