How to use ICommand in key up event of a text box using MVVM architecture?
A:
You have a readymade helper class to handle event to command behaviour in MVVM Light Toolkit.
Veer
2010-06-24 11:13:04
Could you please explain and tell me how to get the dll for that toolkit?
2010-06-24 11:36:25
@gowri-ganapathy: check this link for the installation procedure: http://www.galasoft.ch/mvvm/installing/manually/
Veer
2010-06-24 11:52:59
+1
A:
You can use InvokeDataCommand trigger from Expression Blend Samples:
<TextBox>
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyUp">
<si:InvokeDataCommand Command="{Binding MyCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
PL
2010-06-24 14:44:57
A:
MVVM doesn't forbid you to write code-behind - this is a common misunderstanding. You can listen to the KeyUp event of the TextBox in the code-behind file of the View and delegate the call to the ViewModel object.
How this works is shown in the ViewModel sample application of the WPF Application Framework (WAF).
jbe
2010-06-26 11:19:19