Debugging Design-Time WinRT XAML Binding in Blend

One ability that makes developing application with XAML enjoyable is what is known as Blendability (the ability to bind XAML element to design-time data, so a developer/designer can visualize and update UI using Blend or design view in Visual Studio). Although, the design view in Visual Studio is now using parts of Blend, Blend is still a better tool for advanced XAML tasks like creating animation or editing visual states.

To bind design-time data, we can use d:DataContext attribute to create and bind design-time instance.

And you should see the design-time data in Visual Studio design view and Blend.

image

image

Once in a while, you might want to be able to see how Blend loads and binds design-time data. You can do that by looking for the Blend’s XDesProc.exe PID  (For Silverlight application, you should find the PID for Blend.exe).

image

After you get the PID, you can go to Visual Studio, DEBUG –> Attach to Process and select the process with the same PID (i.e., 4404) and make sure you attach to Managed (v4.5, v4.0) code type.

image

After you attach the debugger to Blend, you should be able to set breakpoints, open the XAML page, and debug your C# code.

image

I hope this tip helps. Besides watching how the sample data is loaded, you can also watch any code that is run when the XAML is loaded by Blend’s designer.

Full source code can be downloaded here.

Enjoy coding!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s