我正在使用 GroupedItemsPage.xaml。我已将项目源设置为组列表,其中“组”是我的自定义类,它显示不同的组及其项目。我的问题是我想为每个组添加一个“添加”按钮,以便每次加载组时,无论该组中是否有项目,都会显示“添加”按钮。 第一张图片是我希望我的小组在添加一些项目后的样子。第二张图片是我希望我的组在没有添加任何项目时的样子。我该如何进行?我正在使用以下网格视图样式。
<Style TargetType="GridView" x:Key="GridViewStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GridView">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}">
<ScrollViewer x:Name="ScrollViewer"
TabNavigation="{TemplateBinding TabNavigation}"
HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
IsHorizontalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsHorizontalScrollChainingEnabled}"
VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
IsVerticalScrollChainingEnabled="{TemplateBinding ScrollViewer.IsVerticalScrollChainingEnabled}"
IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
ZoomMode="{TemplateBinding ScrollViewer.ZoomMode}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
BringIntoViewOnFocusChange="{TemplateBinding ScrollViewer.BringIntoViewOnFocusChange}">
<Grid Height="765" Width="2666" Margin="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- Your custom buttons -->
<Grid x:Name="myGrid" HorizontalAlignment="Left" Width="1108" DataContext="{Binding RelativeSource={RelativeSource Self}}" >
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}" Margin="0,0,10,0">
<Image Source="Assets/Untitled.png" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}"/>
</Border>
<StackPanel VerticalAlignment="Top" Height="755" Margin="0,0,0,0">
<TextBlock Text="RoleCenter" Style="{StaticResource PageHeaderTextStyle}" Height="77" Margin="140,50,0,0"/>
<TextBlock Text="{Binding x}" Style="{StaticResource PageHeaderTextStyle}" Height="77" Margin="140,300"/>
</StackPanel>
</Grid>
<ItemsPresenter
HeaderTemplate="{TemplateBinding HeaderTemplate}"
Header="{TemplateBinding Header}"
HeaderTransitions="{TemplateBinding HeaderTransitions}"
Padding="{TemplateBinding Padding}" Margin="1113,10,244,0" />
<StackPanel Width="150" Height="150" Background="#006AC1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,100,0">
<Button x:Name="LoadMore" Content="+" Height="150" Click="Navigate" Width="150" />
</StackPanel>
</Grid>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>