我在Windows Phone 8上遇到过Panorama Control的问题。 创建了一个项目,使用基于WP Panorama项目模板的简单代码来测试问题。 所以我使用INotifyPropertyChanged接口(MVVM)绑定到Observable Collection。
<phone:PhoneApplicationPage
<! ... >
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Panorama control-->
<phone:Panorama ItemsSource="{Binding PageTitles}"
Title="Panorama Test">
<phone:Panorama.HeaderTemplate>
<DataTemplate>
<Grid Width="410" Margin="-2,0,0,0">
<TextBlock d:DataContext="{Binding}" Text="{Binding Title}" HorizontalAlignment="Left" Style="{StaticResource PanoramaItemHeaderTextStyle}" />
</Grid>
</DataTemplate>
</phone:Panorama.HeaderTemplate>
<phone:Panorama.Background>
<ImageBrush ImageSource="/Assets\PanoramaBackground.png"/>
</phone:Panorama.Background>
<phone:PanoramaItem Name="Screen1">
<Grid Margin="0,-6,0,12">
<Border BorderThickness="1" Width="420" Height="500" BorderBrush="#FFFFC700" Background="#FFFFC700"/>
</Grid>
</phone:PanoramaItem>
<phone:PanoramaItem Name="Screen2">
<Grid Margin="0,-6,0,12">
<Border BorderThickness="1" Width="420" Height="500" BorderBrush="#FFFFC700" Background="#FFFFC700"/>
</Grid>
</phone:PanoramaItem>
<phone:PanoramaItem Name="Screen3">
<Grid Margin="0,-6,0,12">
<Border BorderThickness="1" Width="420" Height="500" BorderBrush="#FFFFC700" Background="#FFFFC700"/>
</Grid>
</phone:PanoramaItem>
<phone:PanoramaItem Name="Screen4" >
<Grid Margin="0,-6,0,12">
<Border BorderThickness="1" Width="420" Height="500" BorderBrush="#FFFFC700" Background="#FFFFC700"/>
</Grid>
</phone:PanoramaItem>
</phone:Panorama>
</Grid>
在Visual Studio 2013设计视图中,我看到的单行内容代替了页面内容:
_。di28.Induction.Viewmodels.ItemViewModel
当在模拟器中运行时,它显示为:
Induction.Viewmodels.ItemViewModel
我已经以我能想到和发现的所有方式重组了Binding,但问题仍然存在。 这是Windows Phone 8下Panorama控件的错误吗?
答案 0 :(得分:0)
不确定它是否能解决您的问题,但您误解了一些事情: ItemsSource属性不仅适用于标题,还适用于整个PanoramaItems集合。 在此之后你不应该重新定义每个PanoramaItem,而是使用datatemplate:就像HeaderTemplate一样:
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Panorama control-->
<phone:Panorama ItemsSource="{Binding PageTitles}"
Title="Panorama Test">
<phone:Panorama.HeaderTemplate>
<DataTemplate>
<Grid Width="410" Margin="-2,0,0,0">
<TextBlock d:DataContext="{Binding}" Text="{Binding Title}" HorizontalAlignment="Left" Style="{StaticResource PanoramaItemHeaderTextStyle}" />
</Grid>
</DataTemplate>
</phone:Panorama.HeaderTemplate>
<phone:Panorama.Background>
<ImageBrush ImageSource="/Assets\PanoramaBackground.png"/>
</phone:Panorama.Background>
<phone:Panorama.ItemTemplate>
<DataTemplate>
<phone:PanoramaItem>
<Grid Margin="0,-6,0,12">
<Border BorderThickness="1" Width="420" Height="500" BorderBrush="#FFFFC700" Background="#FFFFC700"/>
</Grid>
</phone:PanoramaItem>
</DataTemplate>
</phone:Panorama.ItemTemplate>
</phone:Panorama>
我现在无法测试,但至少你明白了。希望这有帮助!