Search code examples
c#windows-phone-8pivotitem

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>

Solution

  • 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>