Consider a Windows Phone 7 application with a textbox and an ApplicationButton.

UI:
- <Canvas x:Name="ContentGrid" Grid.Row="1" Height="545" Width="480">
- <TextBlock Text="Enter text here" Canvas.Left="6" Canvas.Top="187" />
- <TextBox x:Name="myTextBox" Text="{Binding Test, Mode=TwoWay}" Height="69" Width="480" Canvas.Left="0" Canvas.Top="209" />
- </Canvas>
Backend:
- namespace WindowsPhoneApplication1
- {
- using System;
- using System.ComponentModel;
- using System.Windows.Controls;
- using Microsoft.Phone.Controls;
-
- public partial class MainPage : PhoneApplicationPage, INotifyPropertyChanged
- {
- private string _test;
- // Constructor
- public MainPage()
- {
- this.InitializeComponent();
-
- this.DataContext = this;
- }
-
- public string Test
- {
- get
- {
- return this._test;
- }
- set
- {
- if (value != this._test)
- {
- this._test = value;
- this.PropertyChanged(this, new PropertyChangedEventArgs("Test"));
- }
- }
- }
-
- #region INotifyPropertyChanged Members
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- #endregion
-
- }
- }
The textbox is bound to a property on the backend (two way binding) and when you click the bottom button the text is saved/send/encrypted/whatever.
Now the problem is that clicking the button doesn’t do a UI –> source binding update as it would do with a normal button.

I enter the text ‘test’ on the TextBlock and IMMIDIATLY click the ApplicationButton. I don’t do anything else. This is a common user practice, he changes something and clicks the save/send/whatsoever button.
This is the result:

Check the Watch 1. As you can see the value is still null. The value is not sent to the _test value. How do we solve this?
You can add the following line to the click event handler:
- this.myTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
So the result will look like this:
- private void AppbarButton1Click(object sender, EventArgs e)
- {
- this.myTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource();
-
- // handle save/send/encrypt/whatever here
- }
There are 3 downsides I think:
- You need to name your TextBlock which (I think) unnecessarily clutters your scope with otherwise unused variables (that’s why we use bindings too!)
- Your UI and ViewModel (in my case) aren’t decoupled 100% anymore. In Windows Phone 7 this is no issue though, since WP7 has no ICommand and I have to couply my UI and ViewModel anyway
- You need to remember to write this line! Which can be quite cumbersome with a lot of application buttons.
And items in a ApplicationBar.MenuItems (ApplicationBarMenuItem) have the same problem. The UI doesn’t push the update to the ViewModel.
I hope this will be fixed in the final version, and I will post this to Microsoft Connect. If anybody has a better solution please feel free to share it.
No Comments »
Hi all,
I tried to display an icon in my Windows Phone 7 application:
<shell:ApplicationBarIconButton x:Name="appbar_button1" IconUri="/Images/appbar.feature.settings.rest.png" Text="Settings" />
By default, when you add an image to the solution folder it sets the build action as Resource, as shown below:
But when you run the application with the Build Action as Resource you will get a result looking like this:
While I really meant an icon looking like this:
How do we fix it?
Set the Build Action to Content!

And this is the result:

No Comments »
Posted by Kristof in 7, Windows
Execute this line in the CMD as Administrator (start > type ‘cmd’ > hit control+shift+enter) and paste this line (rightmousebutton > paste).
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\ /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1
Be sure to DISABLE your Homegroup and to enable file sharing in the Network & Sharing Center
No Comments »
Posted by Kristof in 7, OS, Windows
So yesterday I reinstalled my laptop because some beta driver was acting up, no big deal. I had both of my partitions secured with Bitlocker (and a BIOS password set up) so that my laptop is secure.
After formatting I noticed that my C drive wasn’t encrypted anymore (which is obvious, it was formatted).
But my D drive looked like this:
It was locked. Fortunately I printed my recovery key so I was able to unlock the drive.
Please print the keys, and keep them safe!
No Comments »
Posted by Kristof in OS, Windows
Well not really my computer, but my girlfriend’s. It needed some updating (you know how people are, not updating & stuff).
Adobe Reader already sets 2 programs in startup. A speed launcher and another one which I am too lazy to identify. If your application is too slow then optimize it, don’t treat the symptoms.
Then our good slow friend Java. Always had their speed launcher (symptom treatment!!) in startup, but guess what also added a service.

What the f*ck? I’m moving closer and closer to not install Java on new pcs, since it’s a burdon to manage and keep up to date!
No Comments »
Posted by Kristof in 7, OS
When you right click a music folder in Windows Explorer you get this:
To remove the Shop for music online link put this into a registry file and execute it:
Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\SystemFileAssociations\Directory.Audio\shellex\ContextMenuHandlers\WMPShopMusic]
No Comments »
Posted by Kristof in OS, Vista
For those who like to live on the edge:
Vista SP2 x64 Beta
Vista SP2 x86 Beta
Remember that there is a change when you install this on your workstation you might need to reinstall Vista if problems occurs, I AM NOT RESPONSIBLE for this.
1 Comment »
Let’s say you are one of the gifted persons to have MSDN access.
Let’s say you use Vista 64-bit (I don’t know if the problem occurs on 32-bit).
Let’s say you want to download something from MSDN with Microsoft File Transfer Manager.
And it does not work.
Well use this workaround:
First: download the File Transfer Manager from here.
Download and install the MSI. The default path is c:\Program Files (x86)\Microsoft File Transfer Manager”. Remember this.
Then use Firefox to go to the MSDN website, start a download, and it will prompt you to do something with the default.aspx. Well open that file with the File Transfer Manager. And it works!
Woei!
No Comments »
DO NOT REMOVE user32.dll, even though AVG 8 states that there is a virus in the file.
Doing so will remove the file, and cause a BSOD, and makes your system unable to boot.
It marks the file as infected with Trojan Horse PSW.BANKER4.APSA.
Possibilities are to wait for an update from AVG, or (preferably) upgrade to XP SP3!
11 Comments »
Today an update for Live Mesh was released.
As stated in the title: there is no need to set your country for your .NET passport and computer to the US, which means my ‘tutorial’ is obsolete now.
Try it out, have fun
No Comments »