I don't think it is possible to change resource properties in the code behind for Windows Store apps. Only static resources are supported unlike WPF where there are both static and dynamic resources.
So the alternatives are:
1. In the button click handler, change the visibility on the StackPanel(s) directly.
2. Data bind the visibility property of your StackPanels to single boolean property that the button click handler can make true (visible) or false (collapsed).