Command binding mouse event result
-
Thursday, October 04, 2012 2:14 PM
I have a mode view like this.
public class MouseEnterViewModel { private ICommand mouseEnterCommand; public ICommand MouseEnterCommand { get { if(mouseEnterCommand==null) { mouseEnterCommand =new DelegateCommand<object>(OnButtonMouseEnter); } return mouseEnterCommand; } } public void OnButtonMouseEnter(object obj) { Button b=new Button(); }my issue is OnButtonMouseEnter object is coming null.
my view page end bindings are as following.
<Button Width="250" Height="60" Content="MyButton with MouseEnter" commands:MouseEnterCommand.Command="{Binding MouseEnterCommand}" commands:MouseEnterCommand.CommandParameter="{Binding RelativeSource={RelativeSource Self}}" />In this case I think my Command parameter binding is wrong. Because my MouseEnterCommand class is getting parameter as a button. but in my view model,
public void OnButtonMouseEnter(object obj) obj parameter is coming null.
All Replies
-
Thursday, October 04, 2012 3:46 PM
commands:MouseEnterCommand.Command="{Binding MouseEnterCommand}"Alas this is giving error my side :
Error 1 'Command' is an undeclared prefix. Line 13, position 17.
How is your code atleast running well ?
-
Friday, October 05, 2012 12:49 PM
firtinalim
commands:MouseEnterCommand.Command="{Binding MouseEnterCommand}"Alas this is giving error my side :
Error 1 'Command' is an undeclared prefix. Line 13, position 17.
How is your code atleast running well ?
MouseEnterCommand is a class that contains commands. -
Tuesday, October 09, 2012 3:46 AM
Please upload the relative project to skydrive.com and provide the link, then we try to help you.
There are some samples on how to use the DelegateCommand, you may refer them
http://www.johnpapa.net/5-simple-steps-to-commanding-in-silverlight/
http://www.codeproject.com/Articles/79872/Step-by-Step-Guide-to-Silverlight-4-Command-Bindin

