tags:

views:

674

answers:

2

Hi,

I have code written on my Listbox mouse double click. I have a submit button too in my form . On mouse double click i want a mouse double click event to be fired first and then the button click

Is it possible?

Please reply

Thanks Sharath

A: 

Hi Sharath,

Easiest (and best practise) is simply to put the code for what to do on Button click into a seperate method (say OnOkClicked), then call this method from the Button Click event handler, as well as at the end of the ListBox DoubleClick event handler.

I nice pattern to implement is to implement an ICommand (like Josh Smith's RelayCommand - google it) on your modelview class, bind the button's Command property to it, and then in the list box's DoubleClick handler, invoke the Executed method of the command. This strucutre simplifies maintaining the logic of:

  1. If nothing is selected in the list box, disable the OK button (Command.CanExecute would return false)
  2. If something is selected in the list box, enable the OK button
  3. If the list box is double clicked, select an item and invoke the OK command.

Hope this helps.

Mark
What i am trying to achieve is i have a popup like window which has Listbox. On double click of the Listboxitem it should pass the values to the parent window textbox. I was trying to make the button to visible false and on double click of the listbox item it will fire a button click. I am using button because it has CommandProperty and CommandParameterproperty. Please help...
A: 

you can make your own control and implement ICommandSource which will give you the same properties

Jamel