Click here to Skip to main content
15,895,799 members
Articles / Mobile Apps

Netflix Browser for Windows Phone 7 - Part 1

Rate me:
Please Sign up or sign in to vote.
4.95/5 (58 votes)
17 Mar 2011CPOL15 min read 219.6K   1.1K   92  
Learn how to use the Pivot and Panorama controls, page navigation, OData and more!
<phone:PhoneApplicationPage 
    x:Class="NetflixBrowser.GenreDvds"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:converter="clr-namespace:NetflixBrowser.Converters" 
    xmlns:local="clr-namespace:NetflixBrowser" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">


    <UserControl.Resources>
        <converter:StringFormatConverter x:Key="StringFormatConverter" />
        <converter:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />    
    </UserControl.Resources>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent" >
        <StackPanel Grid.Row="1" 
            Visibility="{Binding Loaded, 
                        Converter={StaticResource BooleanToVisibilityConverter}, 
                        ConverterParameter=Collapsed}"   
            Height="150" >
            <TextBlock Text="Loading..." Style="{StaticResource PhoneTextTitle2Style}"
                HorizontalAlignment="Center" Margin="20"/>
            <ProgressBar IsIndeterminate="{Binding Busy}"
                Visibility="{Binding Loaded, 
                            Converter={StaticResource BooleanToVisibilityConverter}, 
                            ConverterParameter=Collapsed}" />
        </StackPanel>

        <!--Pivot Control-->
        <controls:Pivot  x:Name="SelectedGenre" Title="{Binding SelectedGenreName}" Visibility="{Binding Loaded, 
                        Converter={StaticResource BooleanToVisibilityConverter}, 
                        ConverterParameter=Visible}">

            <!--Pivot item one-->
            <controls:PivotItem Header="all">
                <ListBox Margin="0,0,-12,0" ItemsSource="{Binding GenreTitles}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,20">
                                <Image  CacheMode="BitmapCache" Source="{Binding BoxArt.LargeUrl}" Margin="12,0,9,0"/>
                                <StackPanel Width="311">
                                    <TextBlock Text="{Binding Name}" TextWrapping="Wrap" 
                                               Style="{StaticResource PhoneTextLargeStyle}"/>
                                    <TextBlock Text="{Binding ShortSynopsis}" TextWrapping="Wrap" Margin="12,-6,12,10" 
                                               Style="{StaticResource PhoneTextSubtleStyle}"/>                                 
                                    <StackPanel Orientation="Horizontal" >
                                        <TextBlock  Margin="12,5,5,5" Text="Rating:" 
                                                    Style="{StaticResource PhoneTextNormalStyle}"/>
                                        <TextBlock  Margin="0,5,0,5" Text="{Binding AverageRating}" 
                                                    Style="{StaticResource PhoneTextNormalStyle}"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock  Margin="12,5,5,20" Text="Available: " Style="{StaticResource PhoneTextNormalStyle}"/>
                                        <TextBlock Margin="0,5,0,20" 
                                                   Text="{Binding Dvd.AvailableFrom, 
                                                    Converter={StaticResource StringFormatConverter}, ConverterParameter=\{0:d MMMM yyyy\}}" 
                                                   TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}"/>
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>

            <!--Pivot item two-->
            <controls:PivotItem Header="latest">
                <ListBox Margin="0,0,-12,0" ItemsSource="{Binding GenreTitlesByYear}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,20">
                                <Image  CacheMode="BitmapCache" Source="{Binding BoxArt.LargeUrl}" Margin="12,0,9,0"/>
                                <StackPanel Width="311">
                                    <TextBlock Text="{Binding Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}"/>
                                    <TextBlock Text="{Binding ShortSynopsis}" TextWrapping="Wrap" Margin="12,-6,12,10" 
                                               Style="{StaticResource PhoneTextSubtleStyle}"/>
                                    <StackPanel Orientation="Horizontal" >
                                        <TextBlock  Margin="12,5,5,5" Text="Rating:" Style="{StaticResource PhoneTextNormalStyle}"/>
                                        <TextBlock  Margin="0,5,0,5" Text="{Binding AverageRating}" 
                                                    Style="{StaticResource PhoneTextNormalStyle}"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock  Margin="12,5,5,20" Text="Available: " Style="{StaticResource PhoneTextNormalStyle}"/>
                                        <TextBlock Margin="0,5,0,20" 
                                                   Text="{Binding Dvd.AvailableFrom, 
                                            Converter={StaticResource StringFormatConverter}, ConverterParameter=\{0:d MMMM yyyy\}}" 
                                                   TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}"/>
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                  </ListBox>
            </controls:PivotItem>
            
            <!--Pivot item tree-->
            <controls:PivotItem Header="top 10">
                <ListBox Margin="0,0,-12,0" ItemsSource="{Binding GenreTitlesByRating}">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,20">
                                <Image  CacheMode="BitmapCache" Source="{Binding BoxArt.LargeUrl}" Margin="12,0,9,0"/>
                                <StackPanel Width="311">
                                    <TextBlock Text="{Binding Name}" TextWrapping="Wrap" Style="{StaticResource PhoneTextLargeStyle}"/>
                                    <TextBlock Text="{Binding ShortSynopsis}" TextWrapping="Wrap" Margin="12,-6,12,10" 
                                               Style="{StaticResource PhoneTextSubtleStyle}"/>
                                    <StackPanel Orientation="Horizontal" >
                                        <TextBlock  Margin="12,5,5,5" Text="Rating:" Style="{StaticResource PhoneTextNormalStyle}"/>
                                        <TextBlock  Margin="0,5,0,5" Text="{Binding AverageRating}" Style="{StaticResource PhoneTextNormalStyle}"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock  Margin="12,5,5,20" Text="Available: " Style="{StaticResource PhoneTextNormalStyle}"/>
                                        <TextBlock Margin="0,5,0,20" 
                                                   Text="{Binding Dvd.AvailableFrom, 
                                            Converter={StaticResource StringFormatConverter}, ConverterParameter=\{0:d MMMM yyyy\}}" 
                                                   TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}"/>
                                    </StackPanel>
                                </StackPanel>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>
        </controls:Pivot>
     </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="appbar_button1" IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton x:Name="appbar_button2" IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="menuItem1" Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem x:Name="menuItem2" Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->
    
</phone:PhoneApplicationPage>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Product Manager Outcoder
United States United States
Katka has several years of experience working in software development in the areas of market research and e-commerce. She has wide ranging experience in developing Java, ASP.Net MVC, ASP.Net, WPF, Silverlight, and Windows Phone applications.

Company: Outcoder.com
Group: XAML Experts
Proud co-creator of: Surfy browser, Airlock Browser

Comments and Discussions