This is a migrated thread and some comments may be shown as answers.

Adding a commandparameter to KeyBinding

3 Answers 156 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jason Mesches
Top achievements
Rank 1
Jason Mesches asked on 18 Dec 2009, 02:36 AM
Hi,

Using a VM pattern and trying to bind my the <ENTER> key to a command that is on my ViewModel.  This seems to work as long as I make the property static and access the static constructor as outlined.  The issue comes with trying to bind a command parameter to the value of a RadMaskedTextbox.  This is to implement search capability... the textbox has the search criteria and the <ENTER> key triggers the search.  The command seems to fire just fine, no matter what I try I can't seem to get the command parameter to be wired to my textbox. 

And yes, btw, the textbox does have an x:Name

Thanks,
---Jason


3 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 23 Dec 2009, 08:08 AM
Hi Jason Mesches,

Wich command patter implementation you are using? Do you have the same problem with a normal textbox, or just with the MaskedTextBox?


Regards,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jason Mesches
Top achievements
Rank 1
answered on 29 Dec 2009, 08:19 PM
Hi, Valentin

Thanks for the reply.  Here's what I found.  First issue is with the RadMaskedTextBox... we had the Mask set to "none" and apparently there are still issues with that setting.  Once I corrected that, I was up against the fact that key bindings don't support CommandParameter as a dependency property which makes binding difficult.

We're trying to remove all code from our views and only bind to our view models... maybe you can point me to a decent implementation of a search pattern (e.g. search customer by phone number) with telerik controls that binds to a view model without code-behind?

I found a few examples of something similar online, but they all seem to involve heavy use of static methods and constructors and that smells of "hack" to me.  I think we may end up setting up the bindings in code (in the view model) anyway for our project.  The issue I'm facing now is that I have to reference the control when using SetInputBindings as the first parameter is a reference to the control the bindings are attached to (CommandManager.SetInputBindings(myView.myTextBox, inputBindingCollection)) -- and that part about specifically referring to the control is troublesome to me.  Any ideas on how to get around my ViewModel knowing that much about the View?

Thanks,
---Jason
0
Ivan
Telerik team
answered on 05 Jan 2010, 04:39 PM
Hello Jason,

Actually you should code behind at least for the command and key bindings. About using the value of the RadMaskedTextBox - you can bind it to a property of your view model. Please preview the attached example and let us know if you have other questions.

Regards,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Jason Mesches
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Jason Mesches
Top achievements
Rank 1
Ivan
Telerik team
Share this question
or