Click here to Skip to main content
12,350,443 members (24,468 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

15K views
1 bookmarked
Posted

Working with Default FontSize in Windows Phone 7 Applications

, 18 Aug 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
In this post, we will learn about various font sizes defined in the default style library of Windows Phone 7, so you don't have to define them again and can reuse those styles which will be standard sizes all over any Phone 7 Application

Hope you already read my article series "Collection of Windows Phone 7 (Mango) Tutorials". During the tutorial series, we used the common styles "PhoneTextNormalStyle" and "PhoneTextTitle1Style" in the TextBlocks added to the TitlePanel. So what are those? These are all common styles defined by the style library of WP7 SDK.

In this post, we will learn about various font sizes defined in the default style library of Windows Phone 7. So, you don't have to define them again and can reuse those styles which will be standard sizes all over any Phone 7 Applications. Let's discuss them here. Read to know more about it. 

Background

In XAML pages of Windows Phone 7, you will find the default styles used in the XAML for titles inside the TitlePanel. They uses some default font sizes internally and if you want to use them in your application, you can follow this post to understand them easily. 

The font sizes are already defined for generic Windows Phone 7 applications to keep standard between all Phone 7 applications. Let's start with their definitions first and then we will see a demonstration of them.

Default Style Definitions

The default font sizes for any WP7 applications are defined in various levels as mentioned below:

FontSize Style Name FontSize
PhoneFontSizeSmall 14 pt
PhoneFontSizeNormal 15 pt
PhoneFontSizeMedium 17 pt
PhoneFontSizeMediumLarge 19 pt
PhoneFontSizeLarge 24 pt
PhoneFontSizeExtraLarge 32 pt
PhoneFontSizeExtraExtraLarge 54 pt
PhoneFontSizeHuge 140 pt

This table is based on MSDN Documentation. No need to define them once again in your application. You can use them directly as per your need.

Demonstration

Let's have a demonstration of the FontSize in a small application. Create a new Windows Phone 7 application and modify the ContentPanel of the MainPage.xaml file as mentioned below:

<Grid x:Name="ContentPanel" Grid.Row="1">
    <StackPanel Orientation="Vertical">
        <TextBlock Text="Small" FontSize="{StaticResource PhoneFontSizeSmall}"/>
        <TextBlock Text="Normal" FontSize="{StaticResource PhoneFontSizeNormal}"/>
        <TextBlock Text="Medium" FontSize="{StaticResource PhoneFontSizeMedium}"/>
        <TextBlock Text="Medium Large" 
	FontSize="{StaticResource PhoneFontSizeMediumLarge}"/>
        <TextBlock Text="Large" FontSize="{StaticResource PhoneFontSizeLarge}"/>
        <TextBlock Text="Extra Large" 
	FontSize="{StaticResource PhoneFontSizeExtraLarge}"/>
        <TextBlock Text="Extra Extra Large" 
	FontSize="{StaticResource PhoneFontSizeExtraExtraLarge}"/>
        <TextBlock Text="Huge" FontSize="{StaticResource PhoneFontSizeHuge}"/>
    </StackPanel>
</Grid>

Here each text block defines a different style from the standard style library. This will render the UI in the Windows Phone 7 screen as shown here:

screenshot_8-17-2011_21.10.34.271

Hope this post was helpful to you to understand the basic and standard font sizes. Stay tuned to read more tips on Silverlight and Windows Phone 7 in the coming days. Thanks for your time to read my blog posts. Don't forget to share them with your followers.

License

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

Share

About the Author

_Kunal Chowdhury_
Software Developer (Senior)
India India
Kunal Chowdhury is a Microsoft "Windows Platform Development" MVP (Most Valuable Professional), a Codeproject Mentor, Telerik Developer Expert, Nokia Developer Champion, Windows 10 Champion, Microsoft Rockstar, Speaker in various Microsoft events, Author, passionate Blogger and a Software Engineer by profession.

He is currently working in an MNC located in India. He has a very good skill over XAML, C#, Silverlight, Windows Phone, WPF and Windows Store (WinRT) app development. He posts his findings, articles, tutorials in his technical blog and CodeProject.

Technical Blog: http://www.kunal-chowdhury.com
Facebook: http://facebook.com/blog.kunal
Twitter : http://twitter.com/kunal2383

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160621.1 | Last Updated 18 Aug 2011
Article Copyright 2011 by _Kunal Chowdhury_
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid