A new home

I’ve made the move to WordPress!

You should be automatically redirected in 5 seconds. Please visit World Wide Code on Wordpress

Hope to see you there!
Showing posts with label Panorama. Show all posts
Showing posts with label Panorama. Show all posts

Wednesday, August 10, 2011

Theme dependent panorama background

Windows Phone 7 provides various theme based resource which change automatically depending on the currently selected theme i.e. dark or light.

You can use these resources for all controls except the case of a panorama background. In such a case you can use a Brush property in your view model to change the panorama background depending on the currently selected theme.


public ImageBrush PanoramaBackgroundImage
{
  get
  {
    var lightThemeEnabled = (Visibility)Application.Current.Resources
["PhoneLightThemeVisibility"] == Visibility.Visible

    var url = lightThemeEnabled ? "/Images/PanoramaBackground_light.jpg"
                             : "/Images/PanoramaBackground_dark.jpg";

    var brush = new ImageBrush
    {
        ImageSource = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute))
    };
    return brush;
  }
}

The only thing left is to bind the background of the panorama to this property. You may also need to add a design time value to this field for design time rendering purposes.

Related Links

Monday, March 28, 2011

News reader: Windows Phone 7 Panorama App


Every one must have header about the panorama control available for the Windows Phone 7 applications. But have you created an app using it? Let's begin creating a simple news reader app using the panorama control.
At first, create a panorama application project in Visual Studio 2010. This adds a lot of files to your project, you may choose to just modify than or add your own files. The basic structure that VS 2010 creates for you is perfect for this app. Let us first concentrate on the UI design.
The app will have two panorama screens, the first one will display the top stories, while the other will show a list of news categories for the user to choose.
Every panorama screen has a title, that identifies what the screen is about or what you can expect it to have. I would be naming my screen "top stories". You might wonder why the lower case, well that's what most of the WP7 apps have titles, all in lower case.
The content of the screen is pretty straight forward, it contains a list box display all the news stories.
<!--Panorama item one-->
<PanoramaItem Header="top stories">

<ListBox ItemsSource="{Binding TopStories}" SelectionChanged="MainListBox_SelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,17" Width="432">
<TextBlock Text="{Binding Title}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle2Style}"/>
<TextBlock Text="{Binding PublishedDate}" TextWrapping="Wrap" Margin="12,5" Style="{StaticResource PhoneTextSmallStyle}" FontStyle="Italic"/>
<TextBlock Text="{Binding Description}" TextWrapping="Wrap" Margin="12,2" Style="{StaticResource PhoneTextSubtleStyle}"/>
<!--StackPanel>-->
</DataTemplate>
<!--ListBox.ItemTemplate>-->
<!--ListBox>-->
</PanoramaItem>
When the user selects any item in the list box, the user would be redirected to the browser display the entire article.  Following code accomplishes this task for you.

Sunday, February 27, 2011

Panorama versus Pivot: Windows Phone 7


The most popular controls in the Windows Phone 7 tools are the Panorama and pivot. Their usage is somewhat similar, but both provide a different kind of experience.
Here's a link to a post from Tim Heuer's blog, Pano versus Pivot: Windows Phone Design Days content available.
The post provides good insights on the two controls and has links to some good learning videos on windows phone 7.
If you are interested in a much more detail look into the implementation of these two controls consider visiting Windows Phone 7 - Part #5: Panorama and Pivot controls