Hello,
I have a simple WM7 Page with a TextBox
. Futher, I assigned EventToCommand
(a RelayCommand<string>
) to this TextBox
, reacting to the TextChanged
event. For testing pourposes I made additional method TextBox_TextChanged
in the page's code behind. Both the command and TextBox_TextChanged
print a message box with the textbox content.
Initial value of the TextBox
is "ABC"
. Then I press D and:
TextBox_TextChanged
printsABCD
.- The command prints
ABC
. D is missing.
Why is the command so fast?
Command declaration:
public RelayCommand<string> TextChanged {get; private set;}
Command initialization:
TextChanged = new RelayCommand<string>((s) => MessageBox.Show(s));
Command binding:
<TextBox x:Name="SearchTextBox" Margin="10,0" TextWrapping="Wrap" Text="{Binding SearchString, Mode=TwoWay}" FontStyle="Italic" TextChanged="SearchTextBox_TextChanged" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding TextChanged, Mode=OneWay}" CommandParameter="{Binding Text, ElementName=SearchTextBox}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>