简体   繁体   中英

Add Button in Pivot control Windows phone

I am new to windows phone,

I want to add button only in Pivot item two is it possible to add ?

<!--Pivot Control-->
        <phone:Pivot Margin="0,20,0,0">

           <!--Pivot item one-->
              <phone:PivotItem Header="one">
                   **I Want to add Button here**

                   **I Want to add LongListSelector here**
              </phone:PivotItem>


           <!--Pivot item two-->
             <phone:PivotItem Header="two">
                   ....
             </phone:PivotItem>


           <!--Pivot item three-->
             <phone:PivotItem Header="three">
                   ....
             </phone:PivotItem>

</phone:Pivot>

Please help and thanks in advance.

Edit:

<phone:PivotItem Header="Events" Margin="12,74,12,0">

                    <StackPanel>

                    </StackPanel>


                <StackPanel>
                    <phone:LongListSelector Margin="0,-20,-12,0" ItemsSource="{Binding Items}">
                        <phone:LongListSelector.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Margin="0,0,0,17">
                                    <TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                </StackPanel>
                            </DataTemplate>
                        </phone:LongListSelector.ItemTemplate>
                    </phone:LongListSelector>

            </StackPanel>
            </phone:PivotItem>

Yes it is possible. This may be really help you

<phone:Pivot Margin="0,20,0,0">
 <!--Pivot item one-->
  <phone:PivotItem x:Name="pivotitem1">
   <phone:PivotItem.Header>
    <StackPanel>
     <Button Content="Pivot Header" Width="100"/>
    </StackPanel>
  </phone:PivotItem.Header>
   <StackPanel>
   </StackPanel>
  </phone:PivotItem >
 <!--Pivot item two-->
  <phone:PivotItem Header="two">
                   ....
   </phone:PivotItem>
   <!--Pivot item three-->
    <phone:PivotItem Header="three">
                   ....
    </phone:PivotItem>

</phone:Pivot>

Edit

    <phone:PivotItem Header="Events" Margin="12,74,12,0">
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="10,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

     <Button Content="Pivot Header" Width="100" Grid.Row="0"/>
                    <StackPanel Grid.Row="1">
                        <phone:LongListSelector Margin="0,-20,-12,0" ItemsSource="{Binding Items}">
                            <phone:LongListSelector.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Margin="0,0,0,17">
                                        <TextBlock Text="{Binding LineOne}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                    </StackPanel>
                                </DataTemplate>
                            </phone:LongListSelector.ItemTemplate>
                        </phone:LongListSelector>

                </StackPanel>
</Grid>
                </phone:PivotItem>

Yes it's possible For Long List Selector You Need to Add Some More

 <phone:Pivot Margin="0,20,0,0">
        <!--Pivot item one-->
        <phone:PivotItem x:Name="pivotitem1">
            <phone:PivotItem.Header>
                <StackPanel>
                    <Button Content="Header Name " Width="100"/>
                </StackPanel>
            </phone:PivotItem.Header>
            <Grid>
                <phone:LongListSelector
                      x:Name="LongListSelectorName"
                      JumpListStyle="{StaticResource AddrBookJumpListStyle}"
                      Background="Transparent"
                      GroupHeaderTemplate="{StaticResource AddrBookGroupHeaderTemplate}"
                      ItemTemplate="{StaticResource AddrBookItemTemplate}"
                      LayoutMode="List"
                      IsGroupingEnabled="true"
                      HideEmptyGroups ="true" Margin="0,10,0,0"/>
            </Grid>
        </phone:PivotItem >
        <!--Pivot item two-->
        <phone:PivotItem Header="two">
            ....
        </phone:PivotItem>
    </phone:Pivot>

For LongListSelector Add this Code

<phone:PhoneApplicationPage.Resources>
    <DataTemplate x:Key="AddrBookItemTemplate">
        <StackPanel VerticalAlignment="Top" Orientation="Horizontal">
            <Image Width="62" Height="62" Source="/Assets/Alert.png" VerticalAlignment="Top"  Margin="0,0,15,0"/>
            <TextBlock FontSize="30" Width="250" Text="{Binding LastName}" Margin="5,10,0,0" />
            <Button Width="120" Height="70" Content="Invet" Margin="2,2"/>
        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="AddrBookGroupHeaderTemplate">
        <Border Background="Transparent" Padding="5">
            <Border Background="#FF0E62EE" BorderThickness="2" Width="62" 
     Height="62" Margin="0,0,18,0" HorizontalAlignment="Left">
                <TextBlock Text="{Binding Key}" Foreground="{StaticResource PhoneForegroundBrush}" FontSize="48" Padding="6" 
        FontFamily="{StaticResource PhoneFontFamilySemiLight}" HorizontalAlignment="Left" VerticalAlignment="Center"/>
            </Border>
        </Border>
    </DataTemplate>

    <phone:JumpListItemBackgroundConverter x:Key="BackgroundConverter"/>
    <phone:JumpListItemForegroundConverter x:Key="ForegroundConverter"/>
    <Style x:Key="AddrBookJumpListStyle" TargetType="phone:LongListSelector">
        <Setter Property="GridCellSize"  Value="113,113"/>
        <Setter Property="LayoutMode" Value="Grid" />
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Border Background="#FF0E62EE" Width="113" Height="113" Margin="6" >
                        <TextBlock Text="{Binding Key}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="48" Padding="6" 
           Foreground="{Binding Converter={StaticResource ForegroundConverter}}" VerticalAlignment="Center"/>
                    </Border>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</phone:PhoneApplicationPage.Resources>

And Add AlphaKeyGroup.cs File From Hear

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM