无法向网页模板添加按钮

时间:2016-03-24 08:38:40

标签: xaml windows-phone-8.1

如何才能将按钮或其他视觉样式元素添加到Windows Phone 8.1中默认集线器模板的一个hubsection?

我想在ListView上方添加一个刷新按钮。

        <Hub x:Name="Hub" x:Uid="Hub" Header="BuLi Tweet" Foreground="White" Background="{StaticResource RasenHintergrund}">

        <HubSection x:Uid="HubSection1" Header="Aktueller Spieltag" Width="400"
                    DataContext="{Binding Groups[0]}" HeaderTemplate="{ThemeResource HubSectionHeaderTemplate}">
            <DataTemplate>
                <ListView
                    ContinuumNavigationTransitionInfo.ExitElementContainer="True">
                    <GridView                
                    Margin="5,0,0,0"
                    ItemsSource="{Binding Items}"
                    AutomationProperties.AutomationId="ItemGridView"
                    AutomationProperties.Name="Items In Group"
                    ItemTemplate="{StaticResource MatchIcon}"
                    SelectionMode="None"
                    IsItemClickEnabled="True"
                    ScrollViewer.VerticalScrollBarVisibility="Auto"
                    ScrollViewer.VerticalScrollMode="Enabled"
                    ItemClick="ItemView_ItemClick"
                    ContinuumNavigationTransitionInfo.ExitElementContainer="True">
                        <GridView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </GridView.ItemsPanel>  
                    </GridView>
                </ListView>
            </DataTemplate>
        </HubSection>

1 个答案:

答案 0 :(得分:1)

我希望你在listview之前想要第一个中心部分内的按钮。只需添加网格并为Grid定义RowDefinations     

        <HubSection x:Uid="HubSection1" Header="Aktueller Spieltag" Width="400"
                    DataContext="{Binding Groups[0]}" HeaderTemplate="{ThemeResource HubSectionHeaderTemplate}">
            <DataTemplate> 
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Button Content="Refresh" Visibility="{Binding}"/>
                    <ListView Grid.Row="1"
               ContinuumNavigationTransitionInfo.ExitElementContainer="True">
                    <GridView                
                    Margin="5,0,0,0"
                    ItemsSource="{Binding Items}"
                    AutomationProperties.AutomationId="ItemGridView"
                    AutomationProperties.Name="Items In Group"
                    ItemTemplate="{StaticResource MatchIcon}"
                    SelectionMode="None"
                    IsItemClickEnabled="True"
                    ScrollViewer.VerticalScrollBarVisibility="Auto"
                    ScrollViewer.VerticalScrollMode="Enabled"
                    ItemClick="ItemView_ItemClick"
                    ContinuumNavigationTransitionInfo.ExitElementContainer="True">
                        <GridView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VariableSizedWrapGrid Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </GridView.ItemsPanel>  
                    </GridView>
                </ListView>
</Grid>
            </DataTemplate>
        </HubSection>