I wrote a sample to show a coworker how to find all Bindings in a project. BindingFinder uses msbuild apis, xaml apis (from .NET + XAML Toolkit).
See http://robrelyea.com/demos/BindingFinder for links to the code and any future updates.
Example output of this command line app:
C:\Users\rrelyea\Documents\Visual Studio 2010\Projects\Bugz\Bugz>bindingfinder Bugz.csproj
FileName: App.xaml 0 bindings found
FileName: DataDesign.xaml
Binding Path=IterationPath located at (30,18)-(30,18)
Binding Path=Source located at (29,15)-(29,15)
Binding Path=Area4 located at (26,17)-(26,17)
Binding Path=Area3 located at (25,17)-(25,17)
Binding Path=ID located at (24,14)-(24,14)
Binding Path=Title located at (21,14)-(21,14)
FileName: MainWindow.xaml
Binding Path=PUTriage located at (33,32)-(33,32)
Binding Path=IterationPath located at (32,32)-(32,32)
Binding Path=Source located at (31,32)-(31,32)
Binding Path=Area5 located at (28,32)-(28,32)
Binding Path=Area4 located at (27,32)-(27,32)
Binding Path=Area3 located at (26,32)-(26,32)
Binding Path=ID located at (24,28)-(24,28)
Binding Path=Title located at (22,32)-(22,32)
Here is the code that uses the XamlDom to find all bindings:
//Iterate through each XAML file in the project
foreach (string xamlFilePath in projectData.XamlFiles)
{
Console.Write("FileName: " + xamlFilePath);
FileInfo xamlFile = projectData.GetFileInfoFromRelativePath(xamlFilePath);
//Load XAML file into a XamlDom (which ships in the XamlToolkit - http://code.msdn.microsoft.com/xaml)
XamlDomObject rootObject = XamlDomServices.Load(xamlFile.FullName, schemaContext);
//Do a LinQ query on the XamlNodes in the XamlDom to find all {Bindings}
foreach (XamlDomObject objectNode in
from bindings in rootObject.DescendantsAndSelf(bindingXamlType)
select bindings)
{
GenerateOutputForObjectNode(objectNode);
}
}