Button clicked ?

hi all,

i guess, this is simple, but i dont see the error:
i want to know whether a button in a window is clicked or not.
the way i tried does not seem to work:

if (myButton.IsPressed == true)
{
myWindow.Close();
return ActivityExecutionStatus.Closed;
}

any idea, why this is not working


thanks in advance,
.k


Answer this question

Button clicked ?

  • J.Mouzakis

    thanks for your answer. unfortunately i am not very firm with event handlers. :-(
    the executing code for the button lies in another class (which also creates the dialog on which the button is...). from this class the buttons on the dialog are accessible, but the bool IsPressed does not seem to work ...

    maybe you can give me a hint on how to do this with an event handler

    thanks very much,
    regards,
    .k



  • Cas10

    In general when you open a modal dialog the code that opens the dialog does not execute until the dialog is complete. If you are not running it as a modal dialog then it can get interesting as to what code is running when. For example if you do not wait for something to happen the code that opens the dlalog will zip past the open and continue without the dialog even getting any user input. Normally you would see code like this:

    button.Click += handlerMethod;

    or

    button.Click += delegate(object sender, Eventhandler e) {

    ...

    };

    Beyond this you are going to have to work your way through a tutoral or two to start to get the feel for how you write UI code that interacts with the UI elements. There are many good tutorials on the web, many blogs that cover startup issues, and the SDK has a lot of introductions and code sampes.



  • Anthony Zoko

    Where is this code executing The normal method of knowing when a button is pressed is to have a Click event handler assigned to the button.

  • Button clicked ?