开发者

How to Implement the ICommand as DependencyProperty

I am using the implementation give at Bind TextBox on Enter-key press to handle the enter key for text box.

But I am using MVVm pattern for my application. Therefore I have defi开发者_StackOverflowned the ICommand handler in my VieModel class. I want to bind it to view.

The sample application uses

InputBindingsManager.UpdatePropertySourceWhenEnterPressed="TextBox.Text" 

and I want to use

InputBindingsManager.UpdatePropertySourceWhenEnterPressed="{Binding myCommandHandler}"

instead.

Can anybody suggest what modification are required in the code?


You can go for inputbindings for a textbox. in this you can bind a Icommand object to command property ok keybindings

Here is the sample code

<TextBox Text="{Binding Firstname, UpdateSourceTrigger=PropertyChanged}">
                        <TextBox.InputBindings>
                            <KeyBinding Key="Enter" Command="{Binding ValidationCommand}">
 </KeyBinding>
                        </TextBox.InputBindings>
                    </TextBox>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜