简体   繁体   中英

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.

I need to use binding - IsEnabled property of each of the buttons will be bound to another button's property with negation using converter.

I approached interesting problem: how to set the initial values of IsEnabled?

I would bind both buttons to a code-behind property LoggedIn . If LoggedIn is false , the login button is enabled and the logout button is disabled (using the negating converter). Each button would set the LoggedIn property to the respective value.

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