Saturday, September 15, 2012

Avoiding layout displacement after SystemTray visibility changes

Avoiding layout displacement after SystemTray visibility changes

I'm trying to avoid the vertical displacement of the main layout when the upper WP7 SystemTray gets shown or hidden by an user action.

I've been trying to combine the visibility change of the SystemTray with adding a margin to the main layout like so

SystemTray.IsVisible = false; LayoutRoot.Margin = new Thickness(0, 32, 0, 0); 

But the result, as expected, isn't very smooth. I suppose there's something could help xaml-side, but still haven't found what I'm looking for. So.. Is there a better way to do this?

Answers & Comments...

Answer: 1

Keep a grid say grid1 of 32 pixels (same as that of the system tray) in height on top of layout root. And keep opacity of SystemTray as 0.99 such that the system tray overlaps the grid1. Now when its visibility is false, the grid1 will takeover. I haven't tried this, its just a thought which I guess should work. All the best.

The grid height/width will change when user changes orientation (if that is what you are going to do in your app), that has to be kept in mind.

by : Milan Aggarwalhttp://stackoverflow.com/users/1378956




No comments:

Post a Comment

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