Using the Reflection Control in Code-Behind

February 26th, 2007
Posted by granthnk in .NET, General, Styling, WPF, XAML
I’ve had a few people ask how to use the Reflection control in code-behind instead of purely through xaml, so I decided to post a quick example here. There’s not much to it, but it may not be obvious at first, so…First, create an instance of Reflector (either via XAML or procedurally). Below, I’m creating an instance named ref1. Next, set the ReflectionTarget property to the object you wish to reflect (in my case, a Rectangle named ‘rectangleToReflect’). That’s it! I have a little extra code to set the margin and alignment properties of ref1, then I add it to my outermost Grid, ‘LayoutRoot’.     

Are you using the Reflection control in any of your projects? If so, send me a link or a screenshot and I’ll post it here.

private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            // Create new Reflector object
            Reflector ref1 = new Reflector();
            // Set ReflectionTarget (the element to reflect)
            ref1.ReflectionTarget = rectangleToReflect;
            // Set a few layout properties
            ref1.Margin = new Thickness(50, 50, 0, 0);
            ref1.HorizontalAlignment = HorizontalAlignment.Left;
            ref1.VerticalAlignment = VerticalAlignment.Top;
            // Add reflection to LayoutRoot grid
            LayoutRoot.Children.Add(ref1);
        }

Download Reflection Sample Project

Dx3 Conference in May

February 4th, 2007
Posted by granthnk in General

This May brings the first Dx3 Conference to Boston, “a four-day conference and expo filled with intensive workshops and sessions, created for interactive designers and developers who are moving beyond the web browser to deploy rich experiences to the desktop, game consoles, and mobile devices.” Lynda.com events, producer of the FlashForward Conference and Film Festival, is producing Dx3, and I’m excited to be presenting a session entitled Lay of the Land – WPF Tools, Utilities, and Resources.

Dx3 stands for “Design/Develop/Deploy.” Because this conference is not technology or platform specific (i.e. only Flash, or only WPF), the sessions and material presented cover a range of topics you don’t typically find at a design conference. I would definitely put this on your must attend list if at all possible.

Dx3 Conference Info
May 15 - 18, Marriot Copley Place, Boston