Setting the Windows Phone 7 SMTP Port

I am now the happy owner of a Windows Phone 7 device, Samsung’s Omnia 7.

I am a happy user of Samsung’s hardware as well as Microsoft’s software, including the new Metro user interface, My Phone’s ability to locate my phone, the Zune software etc. And I am thrilled about the developer story – that apps can be developed using Silverlight and C# with Visual Studio and other familiar tools.

I intend to blog about developing apps as soon as I get proper hands-on experience.

One end-user problem struck me immediately when I tried to setup the phone. I use a hosted email solution which I can use to read my email through POP3/IMAP and I can send email through SMTP, all of which WP7 supports nicely.

Well, except that there seems to be no way to specify the SMTP port to be used, which is odd since it is quite common to have the default port 25 blocked?

As usual, there is a simple solution to this problem – simply specify the port after the SMTP server name. For example, if the server name is ‘myServer.com’ and the port to use is 42, specify this as ‘myServer.com:42:0’.

The Silverlight 3 SelectedIndex bug

There is a Silverlight bug which bothers a lot of users worldwide – if you bing the issue you will find quite a few hits.

The Problem

The problem is simple to state. Create a combo box and bind to the SelectedIndex and ItemsSource properties and you get an out of bounds error when a value is selected.

<ComboBox SelectedIndex="{Binding Path=IndexOfCurrentValue}" ItemsSource="{Binding Values}">

One of the sources that describe the problem is http://www.lhotka.net/weblog/SilverlightComboBoxControlAndDataBinding.aspx. This post includes a work around but I wanted to find a simpler solution.

I asked the Silverlight product team and the answer was that this bug is very unfortunate, but that it may not be trivial to fix.

In my repro project, I bound SelectedIndex before binding ItemsSource, so when the binding engine sets the SelectedIndex property, items are not set yet and the value 0 is not correct.

The Solution

The workaround is simple; simply switch the order of bindings in XAML and bind ItemsSource before binding SelectedIndex.

This is a reported bug and it is still open at the time of writing this. I hope it will be fixed by Silverlight 4.