我正在为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)