About the Author

John Bowen is a Lead Software Engineer with InterKnowlogy. In this role he both develops software and provides technical leadership for large scale projects with larger teams, usually in the areas of WPF, Silverlight and Surface. These include projects which have been the subject of Microsoft case studies and received awards for technology innovation. John is also a Microsoft MVP for Client Application Development and provides training for both clients and at community and Microsoft sponsored events across the U.S. John has been writing software since majoring in computer science at the University of Southern California and at Boston University where he graduated in 2001. He has also pursued an interest in computer graphics since high school, where he won awards for both still and motion graphics. Before joining InterKnowlogy he also worked creating software for the printing and health care industries and writing public facing web and ecommerce sites.

Help improve Visual Studio performance

If you get frustrated by mysterious hangs and long-running operations in Visual Studio 2010 (yes ToolBox, I’m looking at you) there’s often not much you can do about it but sit and wait…

Luckily the VS team wants these problems fixed as much as you do (they write their code in VS too) so to help them identify where people are running into these problems they’ve released a new VS Extension called PerfWatson. It sits in the background and polls VS every few seconds to make sure it’s staying responsive. If VS stops responding, the extension gathers up a report of what you were doing and how long the hang lasted and sends it off to be analyzed and hopefully fixed.

The next version of VS is fast approaching, so the earlier data gets in on things to fix, the better. Go get it now at http://visualstudiogallery.msdn.microsoft.com/fa85b17d-3df2-49b1-bee6-71527ffef441?SRC=Home

Binding to alternate DataContexts

The DataContext is one of the most important parts of the WPF data binding system, especially in MVVM applications. Being built into the Binding type as the common source for bindings in a specific scope reduces plumbing code needed and makes XAML more concise. Unfortunately, for any given element there is only one DataContext available to bind against. Most of the time this isn’t a problem, but complex data hierarchies often lead to situations where an element needs to bind to the DataContext of some parent element in addition to its own local DataContext.

I most often run into this with ItemsControls where something inside the ItemTemplate needs to bind to the ViewModel containing the entire collection:

<ItemsControl ItemsSource="{Binding Items}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <DockPanel>
                <TextBlock Text="{Binding Name}"/>
                <Button Content="Remove" Command="<Remove item command on parent VM>" CommandParameter="{Binding}"/>
            </DockPanel>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

Continue reading

Visualizing Changes Across TFS Branches

Moving individual changes between different branches isn’t difficult but can quickly become a headache to keep track of when dealing with many branches and changesets. Fortunately Visual Studio 2010 has some great tools to track the path of changes across a set of TFS branches.

To begin we can look at the branch structure to get an idea of how everything is related. This view can be accessed from Source Control Explorer by clicking on a branch (MAIN here) and selecting Branching and Merging->View Hierarchy. From this we can see that there is a MAIN branch with Dev and Release branches off of it, each with their own sub-branches.

image

Now if I want to see the state of a changeset across branches I can right click it in the History and select Track Changeset. Continue reading

Event Leapfrogging

(Thanks to Sam Bent from the WPF team for identifying and giving a name to the problem)

Event Leapfrogging is an issue that arises from a combination of two inherent aspects of .NET events: multicasting and synchronous handler execution. A common place that it shows up is in property change handlers in WPF controls and INotifyPropertyChanged objects.

Here’s some code demonstrating the problem: Continue reading

Data driven UIDs for automated WPF UI testing

The Ultimate and Premium versions of Visual Studio 2010 include a new set of tools for creating automated tests that interact with application UI known as Coded UI Tests. One of the tools is a recorder that will generate the appropriate code for you as it monitors your interactions with your application.

Although it is based on older mechanisms for examining the UI (it makes me yearn for the clarity of Snoop), it is still effective at identifying most WPF interactive controls in simple applications. Problems start to arise when working with the more complex data-driven type of applications where WPF excels.

Continue reading

Presentation Materials for Boston Code Camp 14

Thanks to everyone who attended! Sorry we didn’t get through everything but we got lots of great questions!

Reactive Extensions Quickstart: Slides | Code

The code includes both before and after copies of the demo application.

Rx Project home (downloads on the lower right): http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx

Hands on lab: http://blogs.msdn.com/b/rxteam/archive/2010/07/15/rx-hands-on-labs-published.aspx

Rx Wiki: http://rxwiki.wikidot.com/