[英]Phone.Maps- Items collection must be empty before using ItemsSource
[英]WP8 Phone Pivot — Items collection must be empty before using ItemsSource
<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>
我正在使用Visual Studio 2013,它似乎不带$
我做了结帐“在使用ItemsSource之前,Items集合必须为空”。 以及其他此类来源,但仍然无法解决-我不断收到“使用ItemsSource之前,Items集合必须为空”
删除这一部分,您只能拥有一个。
<!--Host View-->
<phone:PivotItem ContentTemplate="{StaticResource GameCardViewTemplate}" />
<!--Computer View-->
<phone:PivotItem ContentTemplate="{StaticResource GameCardViewTemplate}" />
您在XAML中具有ItemsSource或Items,但不能同时具有两者。
正如@III所指出的,您不能同时添加ItemsSource
设置和PivotItem
。
如果您打算从XAML设置PivotItems
的ContentTemplate
而不是填充Pivot
,则可以使用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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.