0
<Grid x:Name="LayoutRoot" Background="Transparent">

    <Grid.Resources>
        <DataTemplate x:Name="GameCardViewTemplate">
            <ScrollViewer VerticalScrollBarVisibility="Hidden">
                <Canvas x:Name="Card" HorizontalAlignment="Left" Height="214" VerticalAlignment="Top" Width="480" Background="#FF760000">
                    <Grid x:Name="CAgeGrid" HorizontalAlignment="Left" Height="84" Margin="0,216,0,0" VerticalAlignment="Top" Width="480" Background="#FF111111" DoubleTap="PlaceBet">
                        <TextBlock x:Name="CAgeL" HorizontalAlignment="Left" Margin="24,36,0,0" TextWrapping="Wrap" Text="Age" VerticalAlignment="Top" FontSize="24"/>
                        <TextBlock x:Name="CAgeV" HorizontalAlignment="Left" Margin="227,36,0,0" TextWrapping="Wrap" Text="{Binding Age}" VerticalAlignment="Top" FontSize="24"/>
                        <TextBlock x:Name="CAgeSep" HorizontalAlignment="Left" Margin="167,40,0,0" TextWrapping="Wrap" Text=":" VerticalAlignment="Top" FontSize="18" FontWeight="Bold"/>
                        <Canvas HorizontalAlignment="Left" Height="84" Margin="104,72,0,-72" VerticalAlignment="Top" Width="100"/>
                    </Grid>
                </Canvas>
            </ScrollViewer>
        </DataTemplate>
    </Grid.Resources>


    <!--Pivot Control-->
    <phone:Pivot x:Name="P0Card" Title="Your Turn" ItemsSource="{Binding CardCollection}">

        <!--Host View-->
        <phone:PivotItem ContentTemplate="{StaticResource GameCardViewTemplate}" />

        <!--Computer View-->
        <phone:PivotItem ContentTemplate="{StaticResource GameCardViewTemplate}" />

    </phone:Pivot>
</Grid>

I am using Visual Studio 2013, which doesn't seem to carry $

I did checkout "Items collection must be empty before using ItemsSource." and other such sources, but still unable to resolve -- I keep getting "Items collection must be empty before using ItemsSource"

Community
  • 1
  • 1
Pallav Bajjuri
  • 65
  • 1
  • 1
  • 4

2 Answers2

1

Remove this part, you can only have one.

    <!--Host View-->
    <phone:PivotItem ContentTemplate="{StaticResource GameCardViewTemplate}" />

    <!--Computer View-->
    <phone:PivotItem ContentTemplate="{StaticResource GameCardViewTemplate}" />

Either you have ItemsSource or Items in XAML but not both.

123 456 789 0
  • 10,565
  • 4
  • 43
  • 72
0

As pointed by @III, you can't have both ItemsSource setting along with PivotItems added directly.

If you intended to set PivotItems's ContentTemplate from XAML instead of populating the Pivot, you can do that using style :

<phone:Pivot x:Name="P0Card" Title="Your Turn" ItemsSource="{Binding CardCollection}">
    <phone:Pivot.Resources>
        <Style TargetType="phone:PivotItem">
            <Setter Property="ContentTemplate" Value="{StaticResource GameCardViewTemplate}"/>
        </Style>
    </phone:Pivot.Resources>
</phone:Pivot>
har07
  • 88,338
  • 12
  • 84
  • 137
  • Thanks, mate. Just got to try this one. Seems to have resolved that problem, but it introduced another one. Binding doesn't seem to be working appropriately, the screen now simply displays the typeof(CardCollection). Will explore that later. If you have any ideas off the top of your head, send them through. Thanks! – Pallav Bajjuri Apr 25 '14 at 05:57