Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将控件布尔属性绑定到布尔应用程序设置的相反?
例如,我想将按钮的“Visible”属性绑定到“!Flag”,即“Flag”是应用程序设置中的布尔字段。
ApplicationSetting 绑定不允许对值应用任何表达式。简单的解决方案是从 Button 派生您自己的控件。例如:
using System; using System.Windows.Forms; class MyButton : Button { public bool Invisible { get { return !Visible; } set { Visible = !value; } } }