WPF CommandParameter in Textbox
command, mvvm, textbox, wpf
Solution
If i want the command to be executed if the user presses enter, i like to use this. Note the clever use of the IsDefault Binding :-)
<TextBox x:Name="inputBox"/>
<Button Command="{Binding CutCommand}"
CommandParameter="{Binding Text, ElementName=inputBox}"
Content="Cut"
IsDefault="{Binding IsFocused, ElementName=inputBox}" />
If you don't want the button to be visible, you can set its visibility to collapsed of course. I think it'll still execute the command if you hit enter.
Problem
I am using MVVM pattern and i have a textbox in parent window and want to send some text to the popup window which will appear on Textchanged. I tried using commandparameter but it is not working for me. Please help.. Thanks Sharath