简体   繁体   中英

2 buttons in xaml wp8 phone:PivotItem

Button "playsound" displays fine by itself, but whenever I add "button2" I get following error:

Property content is set more than once.

and

Invalid Markup.

in my design view. How do I get more than one button on my pivot?

<phone:PivotItem CacheMode="{x:Null}" Header="Audio" Margin="41,30,8,-58">
    <Button x:Name="button2" Margin="61,301,0,0" Content="hello" Height="22" Width="33"></Button>
    <Button x:Name="playsound" HorizontalAlignment="Left" Margin="61,451,0,0"
                               VerticalAlignment="Top" Height="109" Width="256">
        <Grid Height="138" Width="293" RenderTransformOrigin="0.349,0.43">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width ="110"/>
                <ColumnDefinition Width ="110"/>
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Column="0" Margin="0,0,0,68">
                <Run Text="יום ראשון&#10;"/>
                <Run Text="Sunday"/>
            </TextBlock>
            <TextBlock Grid.Column="1" Margin="0,0,0,68">
                <Run Text="פרק כד&#10;"/>
                <Run Text="Psalm 24"/>
            </TextBlock>
        </Grid>
    </Button>                    
</phone:PivotItem>

You should place the two buttons inside a container element such as a Grid or a StackPanel :

<Grid>
    //Buttons here
</Grid>

or

<StackPanel>
    //Buttons here
</StackPanel>

Try this. PivotItem allow only one child element. that's why you getting error. use a Container control like stackpanel or grid as a child of PivotItem .

<phone:PivotItem CacheMode="{x:Null}" Header="Audio" Margin="41,30,8,-58">
<StackPanel>
    <Button x:Name="button2"  Content="hello" Height="22" Width="33"/>
    <Button x:Name="playsound" HorizontalAlignment="Left"  
     VerticalAlignment="Top" Height="109" Width="256">
                        <Grid Height="138" Width="293" RenderTransformOrigin="0.349,0.43">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width ="110"/>
                                <ColumnDefinition Width ="110"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Margin="0,0,0,68">
                                <Run Text="יום ראשון&#10;"/>
                                <Run Text="Sunday"/>
                            </TextBlock>
                            <TextBlock Grid.Column="1" Margin="0,0,0,68">
                            <Run Text="פרק כד&#10;"/>
                            <Run Text="Psalm 24"/>
                            </TextBlock>
                        </Grid>
                    </Button>   
  </StackPanel>                 
 </phone:PivotItem>

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