Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 948753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:17:40+00:00 2026-05-15T23:17:40+00:00

So say I have a button (MyButton) that binds to: public ICommand MyCommand {

  • 0

So say I have a button (MyButton) that binds to:

public ICommand MyCommand { get; set; }

I register this command with:

MyCommand = new DelegateCommand<object>(DoSomething);

Now if I do

MyButton.IsEnabled = false;

It doesn’t do anything, i.e., the button is still enabled. I know that the command is causing this to happen because if I remove the new delegatecommand code above then the button appears disabled.

My questions are:
1. Is there a way for me to tell this binding to a command not to mess with my button’s IsEnabled
2. Is there a way to change the visibility via only the commanding property (which would probably be the more correct way anyway)

Thanks!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:17:41+00:00Added an answer on May 15, 2026 at 11:17 pm

    You need to add logic into your command for the CanExecute delegate, e.g.:

    ICommand comand = new DelegateCommand<object>
        (
        executeMethod: delegate { DoSomething(); }
        ,
        canExecuteMethod: delegate { return _buttonEnabled; }
        );
    
    _buttonEnabled = false;
    
    CommandManager.InvalidateRequerySuggested();
    
    _buttonEnabled = true;
    
    CommandManager.InvalidateRequerySuggested();
    

    The “_buttonEnabled” variable should really represent the state of your application that controls whether the button should actually be enabled or disabled. For example, it could be “_isSomethingDone” and be true\false depending on the state of your application. This would then disable your button whilst “DoSomething” is actually doing something.

    Rough example:

    ICommand saveCommand = new DelegateCommand<object>
        (
        executeMethod: delegate { Save(); }
        ,
        canExecuteMethod: delegate { return _canSave; }
        );
    
    private void Save()
    {
        _canSave = false;
    
        CommandManager.InvalidateRequerySuggested();
    
        //do save...
    
        _canSave = true;
    
        CommandManager.InvalidateRequerySuggested();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a User Control in ASP.NET that contains a button: public class
I have a button that adds a new row to the view with the
For simplicity lets say I have two flex mxml pages. form.mxml button.mxml If the
Say we have the following method: private MyObject foo = new MyObject(); // and
Say I have a class named Frog, it looks like: public class Frog {
I have an object I created in JavaScript. Let's say it looks like this:
I have code similar to the following: public class myButton extends JButton() { public
I have a button, if i were to say click a checkbox, it should
Say I have textboxes, dropdownlists and submit buttons. They are all inline-elements. Which means
I have a few text boxes and buttons on my form. Lets say txtBox1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.