Questions tagged [icommand]

Interface for MVVM scenarios in Silverlight and WPF to bind commands from models to controls (Buttons).

Typically objects implement this interface to enable method calls on the objects through the use of XAML bindings. This is particularly useful in Model-View-ViewModel (MVVM) scenarios, as it allows models to expose commands to which controls such as buttons can be bound to without requiring additional code

481 questions
-1
votes
1 answer

How to implement CanExecuteChanged on Commands which can always be executed

Let's say you want to create an ICommand that can always be executed. Then it's canExecute method should always return true. And the CanExecuteChanged event is basically not very useful. In my mind it would be bad to allow subscribing to an event…
Boris Month
  • 421
  • 6
  • 14
-1
votes
1 answer

wpf The relayCommand needs a constractor that takes parameter

my goal is filter a dataGrid with a textbox input, so i have textbox to filter a datagrid. for all the other commands i used one of these constractors in my **relayCommand ** as follows: // Constructors public RelayCommand(Action action)…
farzadwpf
  • 11
  • 3
-1
votes
1 answer

How to bind a ICommand into a Button out of DataContext?

i have a Button into a DataGrid with a DataContext (KeyValuePair). I want to implementing a Command into this Button. But if i use the Command="{Binding CommandoTest}" it didnt work. I tested the ICommand into a Grid without DataContext and it works…
-1
votes
1 answer

How exactly do Commands get notified to execute their CanExecute?

Imagine, you have a simple WPF window with just a TextBox and a Button on it. The TextBox's Text property is bound to a property called FileName and the Button's Command property is bound to a property called ImportCommand.
Nostromo
  • 1,177
  • 10
  • 28
-1
votes
1 answer

using ICommand in wpf

I want to to replace an event with a an ICommand: private void textBox1_TextChanged(object sender, TextChangedEventArgs e) { textBox2.Text = textBox1.Text; } Is that possible to replace this event with a command, and how can I do so?
Essam Ali
  • 25
  • 7
-1
votes
1 answer

Set up button's IsEnabled property with ICommand

I have the command public class RelayActionCommand : ICommand { /// /// The Action Delegate representing a method with input parameter /// public Action ExecuteAction { get; set; } ///
Bigeyes
  • 1,508
  • 2
  • 23
  • 42
-1
votes
1 answer

Why CanExecute only get called when it's initialized in the constructor of the view model?

I have a Command property, with this definition in the view model: public RelayCommand SaveCommand => new RelayCommand(OnSave, CanSave); whenever the ErrorsChanged of the INotifyDataErrorInfo is fired, RaiseCanExecuteChanged is called in the…
mshwf
  • 7,009
  • 12
  • 59
  • 133
-1
votes
2 answers

Binding a command and DragEnter and Drop events in the same button in WPF

In my WPF MVVM (NET 3.5) app I have below button:
Willy
  • 9,848
  • 22
  • 141
  • 284
-1
votes
2 answers

Can I Access Bound Element From Within Command in Xamarin Forms?

I have a view with an image that has a tap gesture bound to a command: VIEW: var clickableImage = new Image(...); var imageTap = new…
jbyrd
  • 5,287
  • 7
  • 52
  • 86
-1
votes
1 answer

Fill datagrid rows from textbox values?

I have a following wpf i need to fill my datagrid rows from text box values when user enters values in textboxes and press Add Vlan button.I am using MVVM pattern so i created an ICommand interface behind it: My C# code is : #region ICommand …
TheSpy
  • 265
  • 1
  • 8
  • 21
-2
votes
1 answer

Commands from Details view of MVVM Master/Details app fail

Learning MVVM\WPF\C# by building a simple master\details app. I have a MainView which holds the MasterView, DetailView, and ControlsView. I have added buttons (ICommand) to all views. They all work properly except the one on the DetailView. The…
Lone Starr
  • 65
  • 2
  • 8
-2
votes
1 answer

Converting TextBox.Text to Int. (No-Code Behind)

I have not found a solution on the internet that will solve my issue. So I really hope someone can help me. So basically what the Title says. I have this public MyCommand Champion { get { return new MyCommand((id) => …
MummiSnow
  • 13
  • 4
-3
votes
2 answers

MVVM WPF Fire command when image has been loaded (on loaded event)

I have an WPF image control in my view. When image is loaded I want to fire an event that is defined and executed in my model view. How can I do this? I do not know how to do this using a command.
Willy
  • 9,848
  • 22
  • 141
  • 284
-3
votes
1 answer

WPF ICommand Implementation for ComboBoxItem

How can I implement ICommand in WPF(4.5) ComboBoxItem? I tried CommandBinding but I getting error message "Command' property of type 'CommandBinding'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject"
fynl
  • 38
  • 2
-4
votes
1 answer

What are WPF commands for if we almost always use DelegateCommands?

Why WPF commands exists if almost on every situation a DelegateCommand is used, which its only function is to execute a method from the ViewModel instead of WPF directly supporting binding to methods?
Rafael
  • 2,642
  • 2
  • 24
  • 30
1 2 3
32
33