programming4us
programming4us
MOBILE

Themes on Windows Phone 7 Devices (part 1) - Applying a Theme

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
A Windows Phone 7 theme is a combination of a background and an accent color. Users can select from themes that ship with the phone, developers can access them in their code, and companies can alter them to match their own branding colors. Themes are set in the Settings => Themes portion of the Windows Phone 7 device or the emulator.

Themes can also be applied dynamically during the runtime of an application by overwriting or injecting the custom themes into Resources.MergedDictionaries found in Application.Current, as shown in the following code snippet:

ResourceDictionary res = new ResourceDictionary();
res.Source =
new Uri("/MyApplication;component/Assets/MyStyles.xaml", UriKind.RelativeOrAbsolute);
Application.Current.Resources.MergedDictionaries.Add(res);


Currently, there are two possible background settings—Dark (default) and Light. There are ten accent colors to choose from, starting with a Microsoft-ish blue (the default) and ranging all the way to a decidedly 70s lime green.

NOTE

Microsoft recommends you use as little white color as possible (especially in backgrounds), since excessive use of white color may have a negative impact on battery life.

The combination of two background colors and ten accent colors provides the user with a total of twenty possible themes, delivering on the engagement and personalization promise of Metro design principles. Applications automatically adjust to the selected theme and ensure that all UI elements appear consistently across the platform. A quick walkthrough demonstrates theme-awareness of Windows Phone 7 controls and UI elements.

1. Applying a Theme

In this walkthrough, you will add a set of Windows Phone 7 controls to an application, creating some of them with XAML and some through managed code. You will change the theme in the emulator and observe the effect this change has on those controls. Follow these steps to get a better understanding of theming support in Windows Phone 7.

1.1. Creating a User Interface

First, you will add a set of standard controls to a Windows Phone 7 application.

  1. Launch Visual Studio 2010 Express and select the Windows Phone Application template. Change the Project Name to "Theming," select OK, and Visual Studio will set up a new project.

  2. Open MainPage.xaml in design mode and add a text box, textblock, check box, button, and a black rectangular shape to the page. Your end goal is a simple interface that resembles the one in Figure 9-2. Here's the XAML:

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--TitlePanel contains the name of the application and page title-->
    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
    <TextBlock x:Name="ApplicationTitle" Text="THEMES AND COLORS" Style="{StaticResource PhoneTextNormalStyle}"/>
    <TextBlock x:Name="PageTitle" Text="THEMES" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <TextBox Height="72" HorizontalAlignment="Left" Margin="-4,6,0,0" Name="textBox1"
    Text="TextBox" VerticalAlignment="Top" Width="454" />
    <TextBlock Height="30" HorizontalAlignment="Left" Margin="11,80,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" Width="329" />
    <CheckBox Content="CheckBox" Height="72" HorizontalAlignment="Left" Margin="12,116,0,0" Name="checkBox1" VerticalAlignment="Top" />
    <Button Content="Button" Height="72" HorizontalAlignment="Left" Margin="9,194,0,0" Name="button1" VerticalAlignment="Top" Width="160" />
    <Rectangle Height="110" HorizontalAlignment="Left" Margin="249,137,0,0" Name="rectangle1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="156" />
    </Grid>
    </Grid>


1.2. Adding Code to Draw an Elliptical Shape

In addition to using the powerful Visual Designer to add controls to Windows Phone 7 pages, as you just did, you can add controls programmatically. The steps here show you how to do that.

  1. Go to the Theming project in Solution Explorer and open MainPage.xaml.cs (right-click MainPage.xaml and choose View Code).

  2. To add a white ellipse to the page, paste the following code inside the MainPage constructor:

    Ellipse e = new Ellipse();
    e.Width = 100.0;
    e.Height = 120.0;
    e.StrokeThickness = 2.0;

    e.HorizontalAlignment = HorizontalAlignment.Left;
    e.VerticalAlignment = VerticalAlignment.Top;

    Color backgroundColor = Color.FromArgb(255, 255, 255, 255);
    e.Fill = new SolidColorBrush(backgroundColor);
    e.Margin = new Thickness(10, 300, 10, 10);

    ContentPanel.Children.Add(e);

    Figure 1. Theming application user interface layout
Press F5 to run the application. The application screen should now display all of the controls you've added, including a white ellipse.
Other  
  •  Programming the Mobile Web : Mobile Widget Platforms
  •  Programming the Mobile Web : Geolocation and Maps - Showing a Map
  •  Mobile Application Security - BlackBerry Security - Permissions and User Controls (part 2)
  •  Mobile Application Security - BlackBerry Security - Permissions and User Controls (part 1) - RIM Controlled APIs
  •  Windows Phone 7 Development : Working with Controls and Themes - Introducing the Metro Design System
  •  Windows Phone 7 Development : WebBrowser Control - Saving Web Pages Locally
  •  Programming the Mobile Web : Geolocation and Maps - Detecting the Location (part 3)
  •  Programming the Mobile Web : Geolocation and Maps - Detecting the Location (part 2) - Google Gears
  •  Programming the Mobile Web : Geolocation and Maps - Detecting the Location (part 1) - W3C Geolocation API
  •  Programming the Mobile Web : Geolocation and Maps - Location Techniques
  •  
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us