A solution might be to implement a simpler version of the RelayCommand class that simply stores the event handlers itself and exposes a public method to fire them when appropriate: public class RelayCommand : ICommand { public event EventHandler CanExecuteChanged; // Further ICommand implementation omitted... public void Invalidate() { var...
mvvm-light,windows-phone-8.1,relaycommand,commandbinding
OK, so based on the comments, here's the answer - don't use the InvokeCommandAction but the two-way binding. <TextBox Text="{Binding SearchText, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" /> In the viewmodel behind this, there's a property called SearchText which has a setter that can call the LoadContents method, something like this... public string SearchText {...
c#,wpf,xaml,itemscontrol,relaycommand
Currently, you have the button DataContext set to a string "ChromaGUI.MainWindow" : <Button DataContext="ChromaGUI.MainWindow" ....... Command="{Binding RelativeSource= {RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.SendMessageCommand}" CommandParameter="{Binding FullCommandString}"/> String doesn't have property FullCommandString, so your command parameter binding will fail. Simply remove DataContext setting in the button to make it use default DataContext which...
c#,wpf,mvvm,icommand,relaycommand
I am going to presume you're using MVVM and ideally you want to be able to 'handle' the click of the hyperlink in the ViewModel and not in the View - which is the correct way to do this. In which you are probably best using a normal WPF button...
c#,mvvm-light,relaycommand,canexecute
Are you declaring p on the stack in this line and does it still exist when the handler is called? CommandConfirm = new RelayCommand<object>((p) => ConfirmExecute(p), (p) => ConfirmCanExecute(p)); Because an incorrect command binding would certainly cause this to return null, creating the error you're seeing. var passwordBox = parameter...
Thanks for your inputs ,I have solved my problem by adding CommandManager.InvalidateRequerySuggested in my relaycommand implementation. [DebuggerStepThrough] public bool CanExecute(object parameter) { bool result = true; if (_canExecute != null) { result = _canExecute(); CommandManager.InvalidateRequerySuggested(); } return result; } ...
c#,wpf,stackpanel,icommand,relaycommand
You should use CommandParameter property of the button by assigning unique identifier of each notification to it. I'm assuming your notification has an unique integer id: //Add a delete button: var del = new Button(); del.Content = "Slet"; del.FontSize = 24; del.Command = DeleteNotificationCommand; del.CommandParameter = notification.Id; // <-- unique...
c#,wpf,mvvm,multibinding,relaycommand
you said: However, this wont work when its multivalue This assumption is wrong. It does work! When your multiconverter returns array of values, then this array is passed as a parameter to Command.Execute method. new RelayCommand(EnemyPopupTooltipEx, null); public void EnemyPopupTooltipEx(object parameter){ var values = (object[])parameters; } however, this is very...
How about this: var canExecute = this.WhenAny(x => x.kvartal.KanGodkendeBilag, x => x.IsBusy, (bilag, busy) => bilag.Value && !busy.Value); GodkendeBilagCommand = ReactiveCommand.Create(canExecute); ...
wpf,mvvm,icommand,idataerrorinfo,relaycommand
You haven't really added enough code for us to accurately tell you what your problem is. However, you are taking the correct approach. I also use the IDataErrorInfo interface, but I added some extra properties into my base class that implements it: public string Error // actual IDataErrorInfo Member {...