welcome to Qijie's Blog 薛其杰

XAML:

                    <ListBox x:Name="ItemBox" Grid.Column="0" Tap="ItemBox_Tap">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <Grid Width="300" Height="150" Margin="12,0,0,20">
                                    <Border Background="#01BCF3">
                                        <Image Source="" Stretch="UniformToFill" AutomationProperties.Name="{Binding Title}" />
                                    </Border>
                                    <StackPanel VerticalAlignment="Top" Margin="10,0" >
                                        <TextBlock Text="{Binding Title}" TextWrapping="Wrap" Margin="10,0" FontSize="24"  Style="{StaticResource PhoneTextTitle3Style}" />
                                        <!--<TextBlock Text="{Binding PublishDate}" Margin="10,0" FontSize="18" Foreground="#FF8F8F8F"/>-->
                                    </StackPanel>
                                </Grid>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

后台代码:

        private void ItemBox_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            var item = ItemBox.SelectedItem as CourseItem;
            CommonConfig.SelectedItem = item;
            //this is the fake course page in App
            this.NavigationService.Navigate(new Uri("/CoursePage.xaml", UriKind.Relative));
        }

其中ItemBox的数据源是List<CourseItem>.

posted on 2013-07-30 11:58  零点零一  阅读(4283)  评论(0)    收藏  举报