Getting data out of WP7 WMAppManifest is easy with Coding4Fun PhoneHelper
published on: 3/4/2011 | Views: N/A | Tags: C4FToolkit
by WindowsPhoneGeek
In this article I am going to talk about the Coding4fun Toolkit Data Helpers in depth and mainly about the PhoneHelper.
Basically PhoneHelper can be used for getting data out of the WMAppManifest file in an easy way.
What is WMAppManifest?
Windows Phone projects have an auto-generated XML manifest file that contains phone application metadata. The XML manifest file includes information such as product IDs, versioning details, runtime types, paths to resources, phone capabilities, and other application-specific information. The file is automatically updated every time you build or deploy your application. The primary purpose of this file is the following:
-
The Windows Phone Marketplace application submission process uses information from the manifest file. The manifest file supports the submission of applications to the Windows Phone Marketplace (including certification), device marketplace filtering, marketplace-to-device deployment, and device execution.
-
The information from the manifest file is used as the application metadata that will be stored in the application database.
NOTE: Be careful when modifying the WMAppManifest file because your application may become unstable or unusable through file modification. One circumstance in which you should edit the manifest file is when you use the Windows Phone Capability Detection Tool to determine the capabilities used by your application.
Some of the values in the manifest file will be updated or changed after you submit your application to the Windows Phone Marketplace. Examples include the Author and Publisher attributes, which are updated to match your developer account information. Other attributes that are updated include the ProductID, supplied by Windows Phone Marketplace, and the Capabilities section.
NOTE: For more information about WMAppManifest visit the MSDN documentation.
How to use the Codind4Fun PhoneHelper
To begin using PhoneHelper first add a reference to the Coding4Fun.Phone.Controls.dll assembly.
Just create a new folder in your project and add the assembly there, after that add it as a reference to your project.
NOTE: You have to download and rebuild the Coding4Fun Toolkit project in order to generate the assembly.
The next step is to include the using Coding4Fun.Phone.Controls.Data; namespace in code behind.
The sample source code should looks lie:
public MainPage()
{
InitializeComponent();
string versionString = PhoneHelper.GetAppAttribute("Version");
}
Examples
Lest create a sample Windows Phone 7 application project and add a reference to Coding4Fun.Phone.Controls.dll assembly.
![]()
If we open the WMAppManifest.xml we will see the following code:
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">
<App xmlns="" ProductID="{38274f5f-16f4-434a-80b7-04c1628f8c35}" Title="Coding4FunSamples"
RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="Coding4FunSamples author"
Description="Sample description" Publisher="Coding4FunSamples">
...
</App>
</Deployment>
You can use PhoneHelper class for getting data out of the WMAppManifest file n an easy way. Here is an example:
<StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock Text="Version:" FontSize="25"/>
<TextBlock x:Name="Version" Foreground="Red"/>
<TextBlock Text="ProductID:" FontSize="25"/>
<TextBlock x:Name="ProductID" Foreground="Red"/>
<TextBlock Text="Title:" FontSize="25"/>
<TextBlock x:Name="Title" Foreground="Red"/>
<TextBlock Text="RuntimeType:" FontSize="25"/>
<TextBlock x:Name="RuntimeType" Foreground="Red"/>
<TextBlock Text="Author:" FontSize="25"/>
<TextBlock x:Name="Author" Foreground="Red"/>
<TextBlock Text="Description:" FontSize="25" />
<TextBlock x:Name="Description" Foreground="Red"/>
<TextBlock Text="Publisher:" FontSize="25"/>
<TextBlock x:Name="Publisher" Foreground="Red"/>
</StackPanel>
public MainPage()
{
InitializeComponent();
this.Version.Text = PhoneHelper.GetAppAttribute("Version");
this.ProductID.Text = PhoneHelper.GetAppAttribute("ProductID");
this.Title.Text = PhoneHelper.GetAppAttribute("Title");
this.RuntimeType.Text = PhoneHelper.GetAppAttribute("RuntimeType");
this.Author.Text = PhoneHelper.GetAppAttribute("Author");
this.Description.Text = PhoneHelper.GetAppAttribute("Description");
this.Publisher.Text = PhoneHelper.GetAppAttribute("Publisher");
}
And here is the result:
That was all about the PhoneHelper from the Coding4fun Toolkit in depth. You can find the full source code here:
I hope that the article was helpful.
You can also follow us on Twitter @winphonegeek
Comments
Our Top Articles & Free books
- Our FREE e-book: "Windows Phone Toolkit In Depth" 2nd edition
- 400+ Windows Phone Development articles in our Article Index
- 21 WP7 Toolkit in Depth articles covering all controls
- 12 WP7 Coding4Fun Toolkit in Depth articles covering all controls
- Performance Tips when creating WP7 apps
- Creating a WP7 Custom Control in 7 Steps
- WP7 working with VisualStates: How to make a ToggleSwitch from CheckBox
- What makes a WP7 App successful
- Creating theme friendly UI in WP7 using OpacityMask
- Implementing Windows Phone 7 DataTemplateSelector and CustomDataTemplateSelector
- All about Splash Screens in WP7 – Creating animated Splash Screen
- Getting Started with Unit Testing in Silverlight for WP7
- WP7 WatermarkedTextBox custom control
Our Top Tips & Samples
- All about WP7 Isolated Storage series
- WP7 Dynamically Generating DataTemplate in code
- 5 tips for a successful WP7 Marketplace submission
- WP7: Navigating to a page in different assembly
- WP7 ContextMenu: answers to popular questions
- WP7 ListBox: answers to popular questions
- WP7 working with Images: Content vs Resource build action
- WP7 Element Binding samples
- WP7 working with XML: reading, filtering and databinding
- Drawing in WP7: #2 Drawing shapes with finger
- WP7 TextBox Light theme problems - the solution
- Changing the WP7 Panorama Background Image dynamically with Animation
