[英]WPF Property Data binding to negate the property - initial value
I want to create just two buttons: [Login] and [Logout] of which only one will be enabled in the same time. 我想创建两个按钮:[Login]和[Logout],其中只有一个会同时启用。
I need to use binding - IsEnabled property of each of the buttons will be bound to another button's property with negation using converter. 我需要使用绑定 - 每个按钮的IsEnabled属性将绑定到另一个按钮的属性,并使用转换器否定。
I approached interesting problem: how to set the initial values of IsEnabled? 我找到了有趣的问题:如何设置IsEnabled的初始值?
I would bind both buttons to a code-behind property LoggedIn
. 我会将两个按钮绑定到代码隐藏属性LoggedIn
。 If LoggedIn
is false
, the login button is enabled and the logout button is disabled (using the negating converter). 如果LoggedIn
为false
,则启用登录按钮并禁用注销按钮(使用否定转换器)。 Each button would set the LoggedIn
property to the respective value. 每个按钮都会将LoggedIn
属性设置为相应的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.