WPF TextBox Trigger Text changed Event
-
mercoledì 7 marzo 2012 12:28
hi
In reference to the following thread:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/fd819518-605a-46ae-a9e4-26556d0f3e15
I have a issue with the Galasoft dll(I cant use it due to IPR issues)
Is there any other work around to achieve the same without MvvmLightToolKit
Any help will be appreciated.
Tutte le risposte
-
mercoledì 7 marzo 2012 13:41Do you mean to have access to it in your viewmodel?
-
mercoledì 7 marzo 2012 14:40Moderatore
If you are referring to the "Relay Command", it's not Galasoft's IP anyway, they've just made a very nice implementation.
Before I started using MVVMLite I had my own library of such things, as you will find it scattered all over the Internet.
One of the most well known versions/sources for the code of a Relay Command is MSDN Magazine.
public class RelayCommand : ICommand { #region Fields readonly Action<object> _execute; readonly Predicate<object> _canExecute; #endregion // Fields #region Constructors public RelayCommand(Action<object> execute) : this(execute, null) { } public RelayCommand(Action<object> execute, Predicate<object> canExecute) { if (execute == null) throw new ArgumentNullException("execute"); _execute = execute; _canExecute = canExecute; } #endregion // Constructors #region ICommand Members [DebuggerStepThrough] public bool CanExecute(object parameter) { return _canExecute == null ? true : _canExecute(parameter); } public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } public void Execute(object parameter) { _execute(parameter); } #endregion // ICommand Members }Regards,
Pete
#PEJL
- Modificato XAML guyMicrosoft Community Contributor, Moderator mercoledì 7 marzo 2012 14:42
- Proposto come risposta Sheldon _XiaoModerator martedì 20 marzo 2012 10:24
-
giovedì 8 marzo 2012 06:23Moderatore
Hi Parsita,
I think you could refer to AttachedCommandBehavior, there is an AttachedCommandBehavior(ACB) library,
http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/
This feature will help you hook command to any event, and it has provided a complete sample you could refer to.
Best regards,
Sheldon _Xiao[MSFT]
MSDN Community Support | Feedback to us
Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Contrassegnato come risposta Sheldon _XiaoModerator martedì 20 marzo 2012 10:24

