views:

42

answers:

1

How to bind a control Boolean property to contrary of Boolean application setting?

For example I want to bind "Visible" property of a button to "!Flag", that "Flag" is a Boolean field in application settings.

+2  A: 

An ApplicationSetting binding doesn't allow applying any expression to the value. The simple solution is to derive your own control from Button. For example:

using System;
using System.Windows.Forms;

class MyButton : Button {
    public bool Invisible {
        get { return !Visible; }
        set { Visible = !value; }
    }
}
Hans Passant