Tuesday, January 28, 2014

How to implement Semantic Zoom without XAML for Windows 8 / RT in C#

I was experimenting with the Semantic Zoom control and wanted to see how it behaved with controls other than a GridView or ListView.  Here’s a quick and dirty example of how to set it up purely in C#.

mainGrid = new Grid();
SemanticZoom semZoom = new SemanticZoom();
Border brdIn = new Border();
brdIn.Background = CreateSolidColorBrush(Colors.Red);
brdIn.Height = brdIn.Width = 400;
Border brdOut = new Border();
brdOut.Background = CreateSolidColorBrush(Colors.Blue);
brdOut.Height = brdOut.Width = 400;
var gr1 = new GridView();
gr1.Header = brdIn;
var gr2 = new GridView();
gr2.Header = brdOut;
semZoom.ZoomedOutView = gr1;
semZoom.ZoomedInView = gr2;