简体   繁体   中英

What is the actual reason why XAML controls are using 'Visibility' type instead of plain 'bool'?

We all know that XAML UIElements are using property named Visibility of type

public enum Visibility { Visible, Collapsed }

My question is, what is the actual historical(?) reason this property is of type Visibility, instead of just having plain IsVisible property of type bool ?

It would definitely save us lot of time spent on writing/using BoolToVisibilityConverters.

instead of just having plain IsVisible property of type bool?

Because there are multiple values in WPF , not just two. There are:

  • Visibile
  • Collapsed
  • Hidden

Visibility Enumeration - MSDN

WPF has a Visibility state of Hidden. Silverlight does not support the Hidden Visibility state. If you are migrating XAML UI definitions from WPF XAML, you will have to edit any cases that attempt to set a Visibility to Hidden.

Because in WPF, it also has another value. Hidden . This is the same as Collapsed , but it reserves space for it in the layout.

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