Windows Phone 7 TextBox, binding and ApplicationButton

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, […]

A more general INotifyPropertyChangedHandler extension method for strongly typed reflection

static class ExtensionMethods {     public static void Raise<TValue>(this PropertyChangedEventHandler handler, Expression<Func<TValue>> propertySelector)     {         var memberExpression = propertySelector.Body as MemberExpression;           if (handler == null || memberExpression == null)         {             return;         }           var sender = ((ConstantExpression)memberExpression.Expression).Value;         handler(sender, new PropertyChangedEventArgs(memberExpression.Member.Name));     } } Use this as an extension method like this on a class that implements INotifyPropertyChanged […]

MvvmLight: strongly typed INotifyPropertyChanged

Since MvvmLight exposes it’s own ViewModelBase you cannot use this little script to raise the INotifyPropertyChangedEventHandler, because .NET doesn’t allow you to raise events in derived classes. This is because the compiler generates a private delegate (it’s in VB.NET but that doesn’t matter). And since the ViewModelBase only exposes a protected RaiseProperty(string propertyName) I cannot […]

Windows Phone 7, adding and displaying icons.

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 […]