tags:

views:

147

answers:

2

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 Popup 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?

+1  A: 

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.

Ben Von Handorf
@Ben Von Handorf: "...anything that has a UI representation inherits from UIElement and therefore gets the Visibility property... even in cases where it doesn't mean anything." In other words, I can expect to find quite a number of properties that are kind-of useless, just because they are inherited?
cfouche
I don't think many of them will be useless, but it's always possible. This case is somewhat weird, since if they re-used Visibility to mean `Open` that would surprise most developers. This more of an exception case since Popup doesn't have a "normal" visual representation, while almost everything else that inherits from `UIElement` does (I can't think of another counter-example off the top of my head).
Ben Von Handorf
A: 

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.

viky
Yep - I read those two descriptions before posting the question. The Popup.Visibility description says "Gets or sets the user interface (UI) visibility of this element". But that's exactly the thing - it doesn't.
cfouche