tag:blogger.com,1999:blog-3122685766060763329.post4586165433180430037..comments2024-03-14T06:19:08.600+01:00Comments on .NET - Red zone : Best practices and latest stuff: Silverlight: Binding Events to ICommand interface (MVVM)Patric Schoulerhttp://www.blogger.com/profile/05180837550506566896noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-3122685766060763329.post-50279849875668819012011-12-06T19:50:14.307+01:002011-12-06T19:50:14.307+01:00Thanks for the post, but this is not working for m...Thanks for the post, but this is not working for me. One different thing I did was assigning Datacontext to view dynamically.<br />Can you please help me how to bind command when viewmodel is assigned dynamically?iCoderhttps://www.blogger.com/profile/11783768761200377647noreply@blogger.comtag:blogger.com,1999:blog-3122685766060763329.post-80956424168815050172010-09-22T13:41:47.320+02:002010-09-22T13:41:47.320+02:00Ok, I figured it out.
1) Need to reference System....Ok, I figured it out.<br />1) Need to reference System.Windows.Interactivity (http://expressionblend.codeplex.com/)<br />2) Need a basic DelegateCommand<br />public class DelegateCommand : ICommand<br /> {<br /> public event EventHandler CanExecuteChanged;<br /> public Func<object, bool> CanExecuteFunction; <br /> public Action<object> ExecuteAction;<br /> <br /> public bool CanExecute(object parameter)<br /> {<br /> if (CanExecuteFunction == null) return true;<br /><br /> return CanExecuteFunction(parameter);<br /> }<br /><br /> public void Execute(object parameter)<br /> {<br /> if (ExecuteAction == null) return;<br /> <br /> ExecuteAction(parameter);<br /> }<br /><br /> }<br />p.s. I didn't implement the constructor and just used parametrised construction for DelegateCommandAnonymoushttps://www.blogger.com/profile/02021802143138156173noreply@blogger.comtag:blogger.com,1999:blog-3122685766060763329.post-42459317126835461302010-09-22T11:53:43.546+02:002010-09-22T11:53:43.546+02:00I really like what you've done here, but can&#...I really like what you've done here, but can't get it to work. Could you post the project source to download?Anonymoushttps://www.blogger.com/profile/02021802143138156173noreply@blogger.com