Sunday, January 13, 2013

StackPanel.Visibility property not working as expected?

StackPanel.Visibility property not working as expected?

Imagine I keep the below code in button click:

if(condition==true) { Panel1.Visibility = Visibility.Visible; Panel.Visibility = Visibility.Collapsed; } else { Panel.Visibility = Visibility.Visible; Panel1.Visibility = Visibility.Collapsed; } 

Works for the first time and then one of the panel collapses but the other panel doesn't become visible.

Any ideas why this is happening ?

Answers & Comments...

Answer: 1

Could be that the parent of the controls Panel and Panel1 isn't resizing itself when you modify their Visibility. Try putting Panel and Panel1 in a Grid that has 2 rows, each row having its Height set to Auto. I've had success with that hierarchy in the past. If that doesn't work could you post the complete and simplest Xaml that will repro?

by : James Caddhttp://stackoverflow.com/users/82017

Answer: 2

Actually the panels had height set to them when i removed it worked... anyway thanks for answerers

by : Rajahttp://stackoverflow.com/users/0




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog