小编alb*_*bux的帖子

在gridview中选择组样式

我正在为Windows 8开发一个app metro.我使用GridApp(xaml)项目,但我想在每个部分使用不同的组样式.

我的代码是:

public class GroupTemplateSelector : GroupStyleSelector
{

    public GroupStyle NewsItemGroupStyle { get; set; }
    public GroupStyle NormalGroupStyle { get; set; }

    protected override GroupStyle SelectGroupStyleCore(object group, uint level)
    {
        // a method that tries to grab an enum off the bound data object

        if (level == 3)
        {
            return NewsItemGroupStyle;
        }
        else
        {
            return NormalGroupStyle;
        }

        throw new ArgumentException("Unexpected group type"); 

    }
}
Run Code Online (Sandbox Code Playgroud)

我使用这个类来选择组样式和XAML

<!-- NewsItemGroupStyle -->
<GroupStyle x:Key="NewsItemGroupStyle">
    <GroupStyle.HeaderTemplate>
        <DataTemplate>
        </DataTemplate>
    </GroupStyle.HeaderTemplate>
    <GroupStyle.Panel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Vertical" …
Run Code Online (Sandbox Code Playgroud)

c# microsoft-metro windows-8 windows-runtime

5
推荐指数
1
解决办法
3254
查看次数

标签 统计

c# ×1

microsoft-metro ×1

windows-8 ×1

windows-runtime ×1