我定义了自己的ItemsPanelTemplate:
public sealed class ItemsPanel : Panel
{
...
protected override Size MeasureOverride(Size availableSize)
{
Size s = base.MeasureOverride(availableSize);
...
return s;
}
protected override Size ArrangeOverride(Size finalSize)
{
...
return finalSize;
}
}
而不是我在GridView中使用它:
<GridView x:Name="itemGridView"
ItemsSource="{Binding Items}"
IsItemClickEnabled="True"
ItemClick="ItemView_ItemClick"
ItemTemplate="{StaticResource CalendarItemTemplate}">
<GridView.HeaderTemplate>
<DataTemplate>
<StackPanel Background="#182945"
Orientation="Horizontal">
...
</StackPanel>
</DataTemplate>
</GridView.HeaderTemplate>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<controls:ItemsPanel />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
我的问题是标题显示在左侧垂直,但我希望它们在网格水平顶部。