views:

422

answers:

4

how to set the command and command parameter on mouseclick on textbox in xaml?

+1  A: 

TextBoxes don't extend from ButtonBase and therefore don't work with Commands. What you're trying to do is wrong. You should ask another question that states your requirements and asks how best to go about achieving them.

Will
This is how i am doing for textbox enter click. How to do something similar for mouse click as well?<TextBox Text="{Binding Path=Name}" x:Name="txtName"/><Button Command="{Binding NameCommand}" CommandParameter="{Binding Text, ElementName=txtName}" IsDefault="{Binding IsFocused, ElementName=txtName}"/>
A: 

You can use attached command behaviors.

HTH, Kent

Kent Boogaart
A: 

Use the PreviewMouseDown of textbox.

Sauron
A: 

As Ortis Mallum answered, the PreviewMouseDown event does work.

Hada