28 October, 2010

WP7: Typing in the emulator using your own keyboard!

Quick note:

I’ve always been annoyed by the fact that you have to write using the built-in keyboard in the emulator when testing a Windows Phone application. Well – no more:

Press PageUp and you are suddenly using your physical keyboard on the laptop instead of the built-in keyboard in the emulator. Pretty sweet!

26 October, 2010

WP7: Pretty good introduction to WP7-coding

Just came across this blog series by Jeff Blankenburg: http://www.jeffblankenburg.com/post/31-Days-of-Windows-Phone-7.aspx

It really goes through both basic but also small details that you did not know about. Pretty good.

Happy reading!

Technorati Tags:

21 October, 2010

GhostDoc: Assign to key press (Ctrl-D)

If you want to make GhostDoc easy to use; assign the “DocumentThis” to Ctrl-D. It is setup here:


Technorati Tags:

18 October, 2010

How to: Database for WP7

Update (27.04.2011): Native support for SQL CE is coming in May 2011 to the WP7 platform. Therefore, the below database will become more and more obsolete…

There is no support for databases (e.g. SQL Server, CE) on WP7. It will come, I’m sure – but in the initial phase you need to find other means of storing data on the phone for your application needs.

A number of different options exists; but the database I’ve been using for a while is the JubbaDB. It is a simple object database (manifested in a single DLL) that is stored in your applications Isolated Storage. It supports all your existing classes and allows for querying the database tables using LINQ.


The structure is simple; it is a fa├žade (IDatabase) that holds a number of ITables<T> underneath it. It is exposed via a DBFactory class that handles the creation and retrieval of data from IsolatedStorage. The database stores your entire business  objects, and does not split it into different tables with rows and columns etc. It is just plain and simple objects stored (serialized) in the database.


Using the JubbaDB is darn simple too:

//create database
IDatabase db = DBFactory.CreateDatabase("myDB");
Debug.Assert(db != null, "null");

//if no support for “myclass” -> add support

//load table
var tbl = db.LoadTable<MyClass>();

//add data
tbl.Data.Add(new MyClass() { Id = 1, Name = "d1" });
tbl.Data.Add(new MyClass() { Id = 2, Name = "d2" });
tbl.Data.Add(new MyClass() { Id = 3, Name = "d3" });
tbl.Data.Add(new MyClass() { Id = 4, Name = "d4" });

//save table data

The custom classes this table supports is a simple one:

/// <summary>
A custom class
/// </summary>
public class MyClass
public int Id { get; set; }

public string Name { get; set; }

When you want to retrieve data from the database, load the table into memory and query using standard LINQ syntax:

ITable<MyClass> dbTbl = db.LoadTable<MyClass>();
Debug.Assert(dbTbl != null, "null");

//query for data with id = 3
MyClass cls = tdbTblbl.Data.Where(t => t.Id == 3).FirstOrDefault();

Pretty simple and clean!

Download: http://www.clauskonrad.net/download.ashx?id=5

Update history:
- 18.12.2010:
Version 2.0 :
Recently experienced some unfortunate exceptions when using the database in a multithreaded environment. It has now been made thread safe.
- 02.11.2010:
Version 1.0 :
Initial version.

Technorati Tags:

15 October, 2010

WP7: Using DataContractSerializer and internal types => SecurityException

If you want to be able to store types on disk and these types are internal, you can not use the standard XmlSerializer; but will have to use the more recent DataContractSerializer. However - you run into a problem as you will be presented with a SecurityException stating your application failed to communicate with the server. This is in reality nonsense, but you can workaround this problem by adding an InternalsVisibleTo attribute in your assemblyInfo.cs file. This attribute should allow System.Runtime.Serialization assembly to load your internals.

[assembly: AssemblyCopyright("Copyright ©  2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
[assembly: InternalsVisibleTo("System.Runtime.Serialization, PublicKey=00240000048000009400000006020000002400005253413100040000010001008d56c76f9e8649383049f383c44be0ec204181822a6c31cf5eb7ef486944d032188ea1d3920763712ccb12d75fb77e9811149e6148e5d32fbaab37611c1878ddc19e20ef135d0cb2cff2bfec3d115810c3d9069638fe4be215dbf795861920e5ab6f7db2e2ceef136ac23d5dd2bf031700aec232f6c6b1c785b4305c123b37ab")]

Technorati Tags:

14 October, 2010

Fiddler: How to detect/record localhost

Quick info here (cut/paste from fiddlers documentation):

Internet Explorer and the .NET Framework are hardcoded not to send requests for Localhost through any proxies, and as a proxy, Fiddler will not receive such traffic.

The simplest workaround is to use your machine name as the hostname instead of Localhost or So, for instance, rather than hitting http://localhost:8081/mytestpage.aspx, instead visit http://machinename:8081/mytestpage.aspx. 

...Or, just use http://ipv4.fiddler to hit localhost on the IPv4 adapter, or use http://ipv6.fiddler to hit localhost on the IPv6 adapter.  This works especially well with the Visual Studio test webserver (codename: Cassini) because the test server only listens on the IPv4 loopback adapter.”

06 October, 2010

WP7: ToggleSwich, datepicker etc. – where are they?

Having been programming applications for the upcoming WP7 device for some time now; I’ve been looking ridiculously for the missing controls you always see in demos. Look no more – they have been located (on codeplex of all places!).


It includes these missing controls:

  • GestureService/GestureListener
  • ContextMenu
  • DatePicker
  • TimePicker
  • ToggleSwitch
  • WrapPanel

    Download here: http://silverlight.codeplex.com/releases/view/52297

    Technorati Tags:
  • 01 October, 2010

    WP7: Styling controls

    Just found a good (but a bit too detailed at times) posting on how to style your controls (if you so desire). By using Expression Blend, you are basically able to style the controls to the extent that you can’t recognize them any more; so keep a respectful distance here ;-)


    The above buttons are both standard buttons, but the second button has been styled in Expression Blend to have a custom template. None the less, it still supports ButtonClick events etc.

    Link: http://www.thewindowsclub.com/wp7-tutorial-8-creating-a-custom-button-in-expression-blend-1

    Technorati Tags: ,

    iPhone/XCode - not all cases are equal!

    This bit me! Having made some changes to an iPhone application (Obj-C); everything worked fine in the simulator. But, when deploying the s...