简体   繁体   中英

After making whole form disable, how to set one button to be enable?

I'm using WPF, and I have a form, on which there are many textboxes, buttons and whatnot.

For a specific reason I need that whole form to be disabled, which I managed with the code below -

public WPForm() //constructor
    {
        this.IsEnabled = false;            
    }

But, I have one button that sends me back to another form, which I need to be enabled (clickable), and what I have tried is simply setting it like this -

public WPForm() //constructor
    {
        this.IsEnabled = false;   
        btnBack.IsEnabled = true;         
    }

And this does basically nothing, so my question is, what else do I need to do in order to make it enabled?

Just dont set the whole Form to disabled. Try to put a Grid or Stackpanel around the Controls that need to be disabled and disable them only. Maybe like so:

<Grid x:Name="myGrid">
    //Your Controls
<Grid/>
<Button />


public WinForm() //constructor
{
    myGrid.IsEnabled = false;         
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM