steveh
Topic Author
Posts: 42
Joined: 07 Oct 2019, 12:50

UIElement::IsVisibleProperty defaults to true

23 Jul 2021, 17:51

Hi guys,

I thought I'd post a question just to see if this is the intended flow as I'm not sure.

What I have is a UserControl which is collapsed by default:

- Window
-- User Control <-- Collapsed by default
--- ListBox <-- Visible


When I get the ListBox, I test the IsVisible property and it thinks it's visible. The reason for this is because the UserControl is collapsed it is not part of the visual tree, and the IsVisible property is updated whenever the visual element is connected to the tree.

This means that until I make the UserControl visible, the IsVisible will return me the incorrect result. I've fixed this locally by checking:

if (ListBox::IsConnectedToView() && ListBox::GetIsVisible())

But I'm not sure if this is the correct thing to do. I would expect that if something is not connected to a view then GetIsVisible should return false.

Again, I'm not sure if this is a bug per se, just a little oddity. I have a workaround for now so it's not affecting me, I just thought I would check to make sure this is expected behaviour.

Cheers,

-Steven
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: UIElement::IsVisibleProperty defaults to true

23 Jul 2021, 18:18

This is a bug, I just checked with WPF and the default value for that property is false.
Could you please report it in our bugtracker?
 
steveh
Topic Author
Posts: 42
Joined: 07 Oct 2019, 12:50

Re: UIElement::IsVisibleProperty defaults to true

23 Jul 2021, 21:07

Who is online

Users browsing this forum: Google [Bot] and 89 guests