Binding in WPF style causes inexplicable "Cannot find governing FrameworkElement" error

I also cannot explain why the error message happens, but I have found out that adding an x:Name property to the transform is a way to get rid of the error message:

<TranslateTransform x:Name="myTransform" X="{Binding Offset.X}" Y="{Binding Offset.Y}" /> 

I think I found some useful info.

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/db050ce6-d084-41ad-9a31-c01831687683

The answer to this appears to be in the Microsoft explanation of the behavior as an ItemsControl goes through its compositing process and applies bindings and styles. That is, WPF is trying to optimize your DataTemplate before it has a source of data to successfully evaluate the bindings: "dataitem=null". In every other instance during its layout passes, "dataitem" points to something in your "Zones" IEnumerable and it's able to complete the bindings. Otherwise, you'd see the error with each item in your collection, rather than just once per property.

It appears to be a "pay no attention to the man behind the curtain" type of thing. And it should probably be added to MS Connect as a bug report; successful code shouldn't kick out "Error"s that don't matter. But I'll leave it to you to file this with MS Connect if you want.


After reading Rob Perkins' answer, I added a FallbackValue to a binding with this issue. This cleared the error for me.