Tile和longlistselector itemTemplate

时间:2014-01-24 15:03:52

标签: windows-phone-8 longlistselector

我想使用tile创建一个longlistselector的itemtemplate 可能吗? 如何在xaml中做到这一点? 有人可以给我一些代码吗?

2 个答案:

答案 0 :(得分:0)

对于此平铺应用程序,使用longlistselector非常容易。

<phone:PhoneApplicationPage.Resources>
    <DataTemplate x:Key="TileDataTemplate">
        <Grid Background="{StaticResource PhoneAccentBrush}"
              Margin="0,0,12,12">
            <StackPanel VerticalAlignment="Top">
                <TextBlock Text="{Binding Content}" TextWrapping="Wrap"/>
            </StackPanel>

            <StackPanel VerticalAlignment="Bottom">
                <TextBlock Text="{Binding Title}" Margin="6,0,0,6"/>
            </StackPanel>
        </Grid>
    </DataTemplate>
</phone:PhoneApplicationPage.Resources>

<phone:LongListSelector Margin="0,0,-12,0"
                                    SelectionChanged="LongListSelector_SelectionChanged"
                                    LayoutMode="Grid"
                                    GridCellSize="150,150"
                                    ItemsSource="{Binding DataBindingItems}"
                                    ItemTemplate="{StaticResource TileDataTemplate}"
                                    />

这里最重要的是 LayoutMode =“Grid”GridCellSize =“150,150”属性。

修改::: 我已经添加了瓷砖的代码,我将在其中显示一个瓷砖,其中有两个文本块在顶部显示一些内容,然后在最后显示标题。您必须连接一些示例数据或动态的方式取决于后面的代码。如果需要请给我。这是非常基本的东西。如果得到答案,请接受。

答案 1 :(得分:0)

 // find the tile object for the application tile that using "flip" contains string in it.
        ShellTile oTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("flip".ToString()));


        if (oTile != null && oTile.NavigationUri.ToString().Contains("flip"))
        {
            FlipTileData oFliptile = new FlipTileData();
            oFliptile.Title = "Hello WP8!!";
            oFliptile.Count = 11;
            oFliptile.BackTitle = "Updated Flip Tile";

            oFliptile.BackContent = "back of tile";
            oFliptile.WideBackContent = "back of the wide tile";

            oFliptile.SmallBackgroundImage = new Uri("Assets/Tiles/Flip/159x159.png", UriKind.Relative);
            oFliptile.BackgroundImage = new Uri("Assets/Tiles/Flip/336x336.png", UriKind.Relative);
            oFliptile.WideBackgroundImage = new Uri("Assets/Tiles/Flip/691x336.png", UriKind.Relative);

            oFliptile.BackBackgroundImage = new Uri("/Assets/Tiles/Flip/A336.png", UriKind.Relative);
            oFliptile.WideBackBackgroundImage = new Uri("/Assets/Tiles/Flip/A691.png", UriKind.Relative);
            oTile.Update(oFliptile);
            MessageBox.Show("Flip Tile Data successfully update.");
        }
        else
        {
            // once it is created flip tile
            Uri tileUri = new Uri("/MainPage.xaml?tile=flip", UriKind.Relative);
            ShellTileData tileData = this.CreateFlipTileData();
            ShellTile.Create(tileUri, tileData, true);
        }