Some more WP7 development

Jeah, it’s a rainy Sunday, so what do you do =)
Let me share some stuff I’ve learned today…

 

1. Browser

First, I needed a way to open the browser externally. Just dropping the user at a website…
This is done pretty easily.

First you need to include the following namespace

using Microsoft.Phone.Tasks;

and after that a whole lot of “tasks” become available.
Code for jumping towards IE:

WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.URL = "http://www.mendelonline.be";
webBrowserTask.Show();

so that’s one thing 🙂 (thx to windowsphonegeek)

 

2. SMS

Another thing was sending an sms…
This is also done by using a special task.

SmsComposeTask composeSMS = new SmsComposeTask();
composeSMS.Body = "SIM TOPUP 15";
composeSMS.To = "8989";
composeSMS.Show();

It’s the value of the body that is send towards the number of “to” (obviously =) )
More information on ginktage (thx!)

 

3. MessageBox

For some feedback towards the user I needed a confirmation dialog.
The one I used was a eventually a simple messagebox.
Code is as follows:

if(MessageBox.Show("are you sure?", "do something", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
 {
   //some actions
}

Code taken from create.msdn.

 

4. IsolatedStorageSettings

Another thing, I needed settings to be saved.
I had done this previously using IsolatedStorageSettings, but today I encountered some problems…
The returning error was “ArgumentException was unhandled. Value does not fall within the expected range.”.

Apparently this is Microsoft’s way of saying “there is a duplicate value in the storage” 😛

So a “remove” before the “add” solved some issues.

Further I noticed that not everything was saved.
Luckily there is a “save” method available for saving (no shit 😛 )

private IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;
appSettings.Remove("email");
appSettings.Add("email", "someone@contoso.com");
appSettings.Save();
tbResults.Text = (string)appSettings["email"];

Inspiration was found on msdn.

 

5. Weird numbers

While debugging I noticed some weird numbers showing up on the right side of my screen…

No idea what they where doing there, no idea where they came from…

But, Markus Egger brought me the solution

The numbers are some performance counters from VisualStudio, and they only appear while debugging 🙂

Indeed, while running in release or without VisualStudio the numbers don’t even exist.

Another solved problem! Thx @ Markus!

 

6. Pin-to-start

My last submission failed because of the “pin-to-start” icon was still the default…

No idea what this meant, so I rushed to Google. Finding dzone.com with some explanation.

The icon is described in the “WMAPPManifest.xml” file.
Default it’s the file “Background.png”.

So this can of course easily be changed…

 

7. ProgressBar

Last one! Yet again from windowsphonegeek.

I wanted a nice pretty loadingbar as you’ve probably seen in many apps already.

Didn’t found out how to fix this, but eventually it isn’t hard (if you know how to do it! 😛 )

The code is really easy:

ProgressBar bar = new ProgressBar();
bar.IsIndeterminate = true;

this.ContentPanel.Children.Add(bar);

And removing is done by

this.ContentPanel.Children.Remove(bar);

if you make the ProgressBar global available…

 

So, that’s it for today 🙂

Maybe someone can use it 🙂

You saw also some screenshots from 2 apps. Both are pending in the marketplace 🙂 Further updates are coming 😉

Advertenties

Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit / Bijwerken )

Twitter-afbeelding

Je reageert onder je Twitter account. Log uit / Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit / Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit / Bijwerken )

Verbinden met %s

%d bloggers liken dit: