Search Results For : wp7

Windows Phone 7 – Textbox On Focus Color

Was browsing around Stackoverflow and saw a question that someone asked, (WP7DEV) Textbox background changes when typing

Thought it will be useful for someone who needs it.

Explaination:
By default, a textbox on Windows Phone 7 will look at the one you see in the screenshot on the left, below, but when you were to focus on it, it will turn into slightly white-ish, as seen on the right.

Some of the scenarios for your development do not allow that and requires them to be the same. Written this quick guide in case someone needs it.

1. Attach a GotFocus event handler to the textbox you want to have the effect on.
2. Add this code in the method.

textBox2.Background = (SolidColorBrush)Resources[“PhoneTextBoxBrush”];
textBox2.BorderBrush = (SolidColorBrush)Resources[“PhoneTextBoxBrush”];

*Please remember to change textBox2 to the correct id of the textbox that you want the effect on.

For those of you who are curious where I get the Resources from, you can view a list of the available resources here : http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769552(v=vs.92).aspx#BKMK_BrushResources

You can download the solution here too:
https://skydrive.live.com/redir?resid=29F099C37B76CA59!2793&authkey=!ACBRpIRyDopM5Lo

Using Toggle Control to disable/enable idle detection – Windows Phone 7

Saw a question on Dream Build Launch on how can one use toggle control to disable / enable idle detection and from there, enable/disable it idle detection accordingly.

I believe he needed it in his setting page. Did up a quick demo.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Resources
1. I used the toggle control from the silverlight toolkit for Windows Phone on codeplex (Can be found here : http://silverlight.codeplex.com/releases/view/75888) for the toggle control.

2. Do read this msdn article for

Things I did
1. Added the toggle controls in the toolkit into Visual Studio (if you have yet to do so)
2. Pull in the toggle controls and attached the checked event handler onto the control.
3. Add the following code (I included the method signature here).

private void toggleSwitch1_Checked(object sender, RoutedEventArgs e)
{

if (toggleSwitch1.IsChecked == true)
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
else
PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Enabled;
}

You can download the demo file here : https://skydrive.live.com/redir?resid=29F099C37B76CA59!2752&authkey=!AOBimFuXpsh6oog

Windows Phone 7 – Removing Battery Indicator

Many a times, when we do a XNA game, we will want it to be full screen and hide the battery indicator. We will not want to show the battery indicator like this.

With Battery Indicator

With Battery Indicator

You can change it to remove the battery indicator by adding this line of code at the constructor where the game is initialized.
graphics.IsFullScreen = true;

Without Battery Indicator

Without Battery Indicator

You can download and view the sample here.
http://cid-29f099c37b76ca59.office.live.com/self.aspx/Blog/Code%20Guide/Windows%20Phone%207/RemoveBatteryIcon.zip
If you have any feedback, you can email me at guohong@limguohong.com

Error reporting for Windows Phone 7 : Little Watson (XNA version)

Recently I blogged about Error reporting for Windows Phone 7 : Little Watson but when I was using it for the Slime Sweeper V2 , i realised its not as simple as copying and paste the framework over to XNA and use it. We have to introduce some extra stuffs.

I built the XNA version for it. Appreciated the help given by Konaju Games on MSDN forum here and Andy Pennell who have written the original version of Little Watson.

We have to add Microsoft.Phone and System.Windows references into the project. The codes are similar but we do not have native MessageBox.Show and Application.Current.UnhandledException in the project like what we have on Silverlight project and hence we have to add them differently to the project.

In the constructor of the game, we have to add this code.

Application.Current.UnhandledException += (s, e) =>
{
if (!System.Diagnostics.Debugger.IsAttached)
{
try
{
LittleWatson.ReportException(e.ExceptionObject, GetType().Assembly.FullName);
}
catch
{
// We do not want to throw exceptions in our exception handler
}
}
};

and as for MessageBox.Show, I am using Guide.BeginShowMessageBox method.
http://msdn.microsoft.com/en-us/library/dd940233.aspx

Guide.BeginShowMessageBox

You can download the sample code which I have built here, the button will crash the application and when you try to go into the application again from the emulator, a messagebox will appear :
http://cid-29f099c37b76ca59.office.live.com/self.aspx/Blog/Code%20Guide/Windows%20Phone%207/LittleWatsonXNA.zip

If you have any feedback or question, feel free to contact me via the contact me form or email me at guohong@limguohong.com

WPDT 7.1 Comprehensive Developer Documentation

Recently Chris Ismael, Developer Evangelist from Microsoft Singapore posted a blog post on Innovative Singapore on the resources which Microsoft kindly released to help the developer to learn WPDT 7.1 ( Known as Mango )

This blog post consolidate all the samples and walkthrough on how to use WPDT 7.1 http://innovativesingapore.com/2011/05/a-comprehensive-mango-developer-documentation-reference/