Currently viewing the category: "WP7"

Problem:  How to open the Settings screen programmatically in Windows Phone?

Solution: Use the ConnectionSettingsTask from the Microsoft.Phone.Tasks namespace.

C#

using Microsoft.Phone.Tasks; ConnectionSettingsTask task = new ConnectionSettingsTask(); task.ConnectionSettingsType = ConnectionSettingsType.WiFi;
task.Show();

VB

Imports Microsoft.Phone.TasksDim task as ConnectionSettingsTask = new ConnectionSettingsTask()
task.ConnectionSettingsType =
ConnectionSettingsType.WiFi
task.Show()

  • Available Connection Types:
  • AirplaneMode
  • Bluetooth
  • Cellular
  • WiFi

For a complete list of Choosers and Launchers go here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769542(v=vs.105).aspx

Problem:

I have the following line: ShellTile TileToFind = ShellTile .ActiveTiles.First(); to get the first application tile of my Windows Phone 7 application, but First() doesn’t get recognized and I get this error:

Error 2 ‘System.Collections.Generic.IEnumerable<Microsoft.Phone.Shell.ShellTile>’ does not contain a definition for ‘First’ and no extension method ‘First’ accepting a first argument of type ‘System.Collections.Generic.IEnumerable<Microsoft.Phone.Shell.ShellTile>’ could be found (are you missing a using directive or an assembly reference?)

Solution:

Add the following using statement at the top of your .cs file.

using System.Linq;

The following languages are supported:

Culture name

Code WP7 7.0

WP7 7.1

Chinese Simplified (PRC) zh-CN No Yes
Chinese Traditional (Taiwan) zh-TW No Yes
Czech (Czech Republic) cs-CZ No Yes
Danish (Denmark) da-DK No Yes
Dutch (Netherlands) nl-NL No Yes
English (United States) en-US Yes Yes
English (United Kingdom) en-GB Yes Yes
Finnish (Finland) fi-FI No Yes
French (France) fr-FR Yes Yes
German (Germany) de-DE Yes Yes
Greek (Greece) el-GR No Yes
Hungarian (Hungary) hu-HU No Yes
Italian (Italy) it-IT Yes Yes
Japanese (Japan) ja-JP No Yes
Korean (Korea) ko-KR No Yes
Norwegian (Norway) nb-NO No Yes
Polish (Poland) pl-PL No Yes
Portuguese (Brazil) pt-BR No Yes
Portuguese (Portugal) pt-PT No Yes
Russian (Russia) ru-RU No Yes
Spanish (Spain) es-ES Yes Yes
Swedish (Sweden) sv-SE No Yes
For the official documentation click this link: Culture and Language Support for Windows Phone.

Problem: The Account Info section in the App Hub website, seems to hide every time I need it.

Solution: The trick is to click on the “Hi, {account name}” link, on the top right corner (“Hi, The Magic Software” in the sample image below.) That will open the Account Management page, where the Account Info section is.

App Hub Account Info

Problem: The line of code below throws an InvalidCastException exception.

DatabaseSchemaUpdater  ViewModelUpdater = db.CreateDatabaseSchemaUpdater();

Solution:

Try removing the code snippet below from your DataContext class:
public System.Data.Linq.Table <@__VERSION> @__VERSIONs
{
	get
	{
		return this .GetTable<@__VERSION>();
	}
}

 

In practice, you don’t really need a special font to render these type of characters. You can use any sprite font just as you would for displaying basic ASCII characters. For example the ones available for free from Microsoft such as Segoe UI Mono, Andy, Miramonte, etc.
For a complete list, and to download those free font files click here: Redistributable Font Pack

The key is specifying the different character regions in the <CharacterRegions> section of the spritefont xml file, or the individual characters that you want to display. 
For a list of the different regions click Unicode 6.0 Character Code Charts
Now, there are two more important things: one is to specify a default character by setting the DefaultCharacter section of the spritefont xml file, to avoid exceptions when you try to display a character that is not on your defined regions like this:
<DefaultCharacter>?<DefaultCharacter>
And second, some international languages like Japanese and Korean can have thousands of different characters, so including so many characters can be very inefficient or increase the size of your game.
So to build a very efficient game where you only consider characters that you need for your game, rather than manually specifying all the different regions or characters, download this excellent and simple Localization example that uses resource files for the different languages by clicking here.

Yes it is, and the best and easiest way to do that is by creating the Class Library project using the Portable Class Libraries project.
Since the Portable Class Libraries template is an add-in and does not come with Visual Studio by default, you have to install  the Visual Studio 2010 Service Pack 1 (SP1), and the Portable Library Tools.
The official documentation from Microsoft for the Portable Class Libraries is located here: http://msdn.microsoft.com/en-us/library/gg597391.aspx

 

If you renamed the namespace of the App class, make sure the Startup object is set correctly on the Project’s properties.

The reason is, that setting is stored in the .csproj or .vbproj and doesn’t get renamed automatically by the Find and Replace dialog.