UIElement::IsVisibleProperty defaults to true
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
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
-
sfernandez
Site Admin
- Posts: 3005
- Joined:
Re: UIElement::IsVisibleProperty defaults to true
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?
Could you please report it in our bugtracker?
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests