I've played around with the WPF Popup Control and as far as I can see, the Visibility property is superfluous.
If you have a P开发者_如何学Pythonopup with IsOpen = True, it will be visible even if its Visibility = Collapsed.
If you have a Popup with IsOpen = False, then its Visibility will be Collapsed, and will remain "Collapsed" when IsOpen changes to true, and it will appear. (i.e. you'll have something that appears on your screen, even though Snoop says it is Collapsed.)
Why does the Popup control have both these properties? Am I missing something here?
I believe you are correct... it is pretty much superfluous. I think the issue is that the Visibility
property is inherited from UIElement
and could be interpreted to be "Should this have a normal visual representation".
Since a Popup
doesn't have any visual representation in it's "default state... i.e.: when it's closed, the property doesn't mean much. IsOpen
, however, is more of a behavior based property... i.e.: "Should a user be allowed to interact with my normally-hidden contents?". Or perhaps I'm just justifying Microsoft's work, here.
At the end of the day, anything that has a UI representation inherits from UIElement
and therefore gets the Visibility
property... even in cases where it doesn't mean anything.
MSDN gives a complete mean and purpose for both.
Popup.IsOpen - Gets or sets a value that indicates whether the Popup is visible.
Popup.Visibility - Gets or sets the user interface (UI) visibility of this element. It is inherited from UIElement.
精彩评论