Skip to main content
added 3 characters in body
Source Link
bitbonk
  • 49.9k
  • 39
  • 202
  • 286

In MVVM (wich makes a lot of things a lot easier - you should try it) you would have two properties in your ViewModel Text that is bound to your TextBox and you would have a ICommandan ICommand property Apply (or similar) that is bound to the button:

<Button Command="Apply">Apply</Button> 

The ICommand interface has a Method CanExecute that is where you return true if (!string.IsNullOrWhiteSpace(this.Text). The rest is done by WPF for you (enabling/disabling, executing the actual command on click).

The linked article explains it in detail.

In MVVM (wich makes a lot of things a lot easier - you should try it) you would have two properties in your ViewModel Text that is bound to your TextBox and you would have a ICommand property Apply (or similar) that is bound to the button:

<Button Command="Apply">Apply</Button> 

The ICommand interface has a Method CanExecute that is where you return true if (!string.IsNullOrWhiteSpace(this.Text). The rest is done by WPF for you (enabling/disabling, executing the actual command on click).

The linked article explains it in detail.

In MVVM (wich makes a lot of things a lot easier - you should try it) you would have two properties in your ViewModel Text that is bound to your TextBox and you would have an ICommand property Apply (or similar) that is bound to the button:

<Button Command="Apply">Apply</Button> 

The ICommand interface has a Method CanExecute that is where you return true if (!string.IsNullOrWhiteSpace(this.Text). The rest is done by WPF for you (enabling/disabling, executing the actual command on click).

The linked article explains it in detail.

added 1 characters in body; added 63 characters in body; added 117 characters in body
Source Link
bitbonk
  • 49.9k
  • 39
  • 202
  • 286

In MVVMMVVM (wich makes a lot of things a lot easier - you should try it) you would have two properties in your ViewModel Text hatthat is bound to your textboxTextBox and you would have a ICommand property Apply or(or similar) that is bound to the button:

<Button Command="Apply">Apply</Button> 

The ICommand interface has a Method CanExecute that is where you return true if (!string.IsNullOrWhiteSpace(this.Text). The rest is done by WPF for you (enabling/disabling, executing the actual command on click).

The linked article explains it in detail.

In MVVM (wich makes a lot of things a lot easier - you should try it) you would have two properties in your ViewModel Text hat is bound to your textbox and you would have a ICommand property Apply or similar that is bound to the button:

<Button Command="Apply">Apply</Button> 

The ICommand interface has a Method CanExecute that is where you return true if (string.IsNullOrWhiteSpace(this.Text). The rest is done by WPF for you.

In MVVM (wich makes a lot of things a lot easier - you should try it) you would have two properties in your ViewModel Text that is bound to your TextBox and you would have a ICommand property Apply (or similar) that is bound to the button:

<Button Command="Apply">Apply</Button> 

The ICommand interface has a Method CanExecute that is where you return true if (!string.IsNullOrWhiteSpace(this.Text). The rest is done by WPF for you (enabling/disabling, executing the actual command on click).

The linked article explains it in detail.

edited body
Source Link
Robert S.
  • 25.3k
  • 14
  • 87
  • 117

In MVVM (wich makes a lot of things a lot easier - you should try it) you would have two properties in your ViewModel Text hat is bound to your textbox and you would have a ICommand property Apply or similar that is bound to the button:

</Button<Button Command="Apply">Apply</Button> 

The ICommand interface has a Method CanExecute that is where you return true if (string.IsNullOrWhiteSpace(this.TexText). The rest is done by WPF for you.

In MVVM (wich makes a lot of things a lot easier - you should try it) you would have two properties in your ViewModel Text hat is bound to your textbox and you would have a ICommand property Apply or similar that is bound to the button:

</Button Command="Apply">Apply</Button> 

The ICommand interface has a Method CanExecute that is where you return true if (string.IsNullOrWhiteSpace(this.Tex). The rest is done by WPF for you.

In MVVM (wich makes a lot of things a lot easier - you should try it) you would have two properties in your ViewModel Text hat is bound to your textbox and you would have a ICommand property Apply or similar that is bound to the button:

<Button Command="Apply">Apply</Button> 

The ICommand interface has a Method CanExecute that is where you return true if (string.IsNullOrWhiteSpace(this.Text). The rest is done by WPF for you.

added 19 characters in body
Source Link
bitbonk
  • 49.9k
  • 39
  • 202
  • 286
Loading
Source Link
bitbonk
  • 49.9k
  • 39
  • 202
  • 286
Loading