locked
使用 Panorama 的 itemtemplate布局时出现多余的文本? RRS feed

  • 问题

  • <controls:Panorama x:Name="Curriculum" Title="Lessons" ItemTemplate="{StaticResource ItemTemplate}">
                
            </controls:Panorama>

    itemtemplate :

    <DataTemplate x:Name="ItemTemplate">
                <controls:PanoramaItem Header="{Binding Title}">
                    <Grid Width="Auto" Height="Auto">
                        <Image Source="{Binding uri}" Width="Auto" Height="Auto"></Image>
                    </Grid>
                </controls:PanoramaItem>
            </DataTemplate>

    itemsource:

     protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
            {
                CurriculumList.Add(new ImageDescription {Title="base1", uri = "/WP7GoodChinese;component/BasicChinese/BasicChineseLesson1/video_detail.png", lockuri = "" });
                CurriculumList.Add(new ImageDescription { Title = "base1", uri = "/WP7GoodChinese;component/BasicChinese/BasicChineseLesson1/video_detail.png", lockuri = "" });
                CurriculumList.Add(new ImageDescription { Title = "base1", uri = "/WP7GoodChinese;component/BasicChinese/BasicChineseLesson1/video_detail.png", lockuri = "" });
                CurriculumList.Add(new ImageDescription { Title = "base1", uri = "/WP7GoodChinese;component/BasicChinese/BasicChineseLesson1/video_detail.png", lockuri = "" });
                CurriculumList.Add(new ImageDescription { Title = "base1", uri = "/WP7GoodChinese;component/BasicChinese/BasicChineseLesson1/video_detail.png", lockuri = "" });
                CurriculumList.Add(new ImageDescription { Title = "base1", uri = "/WP7GoodChinese;component/BasicChinese/BasicChineseLesson1/video_detail.png", lockuri = "" });
                Curriculum.ItemsSource = CurriculumList;
            }

    求原因。。求帮助。。在此感谢。。

    2012年10月31日 1:41

答案

  • 你好,

    从你的代码来看,你ItemTemplate里嵌套了PanoramaItem,但是你没有为Panorama自己的PanoramaItem指定Header。

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" >
            <Grid.Resources>
                <DataTemplate x:Name="ItemTemplate">
                    <Grid Width="Auto" Height="Auto">
                        <Image Source="{Binding uri}" Width="Auto" Height="Auto"></Image>
                    </Grid>
                </DataTemplate>
                <DataTemplate x:Name="HeaderTemplate">
                    <TextBlock Text="{Binding Title}"/>
                </DataTemplate>
            </Grid.Resources>
            <controls:Panorama x:Name="Curriculum" Title="Lessons" 
                               ItemTemplate="{StaticResource ItemTemplate}"
                               HeaderTemplate="{StaticResource HeaderTemplate}">
            </controls:Panorama>
    
        </Grid>


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    2012年11月1日 6:34
    版主