开发者

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

开发者 https://www.devze.com 2023-01-01 19:26 出处:网络
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 Boolea

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.


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; }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消