I am able to use the MVVM-Light toolkit on my Windows Phone 7 application. Here i have provided my View:
Code:
<TextBox Height="80" HorizontalAlignment="Left" Margin="106,34,0,0" VerticalAlignment="Top" Width="315" Text="{Binding RealVal, Mode=TwoWay}" />
<Button Content="Go" Height="80" HorizontalAlignment="Left" Margin="127,252,0,0" Name="button1" VerticalAlignment="Top" Width="213" cmd:ButtonBaseExtensions.Command="{Binding DoCommand}" />
My view model is :
Code:
public class MainPageViewModel : ViewModelBase
{
public ICommand DoCommand { get; internal set; }
public MainPageViewModel()
{
DoCommand = new RelayCommand(() =>
{
DoSomethingWith(RealVal);
}, () => true);
}
private const string RealValPropertyName = "RealVal";
private string _RealVal;
public string RealVal
{
get { return _RealVal; }
set
{
if (_RealVal == value)
return;
_RealVal = value;
RaisePropertyChanged(RealValPropertyName);
}
}
}
In the emulator, when you type the value on the textbox then clicking on the button will show you see you are in the relaycommand lambda expression and with a breakpoint. I see that RealVal is null. Then, the breakpoint in the setter of RealVal is reached, and the correct value goes in RealValue. What could i do if i want to setter to be reaching before relay command.
Bookmarks