title: How does binding elementname work exactly?
body: <p>I remember reading a couple of weeks ago that it sometimes doesn't work inside templates, and I recently tried to bind things in two different windows and it couldn't find the name declarations, so I assumed that it was local to the namespace of the class and just bound by setting the datacontext instead. However, I'm really curious when I am able to use binding elementname and when I cannot, because it's far more convenient when it is possible.</p>
  
  <p>edit: In reading that article, I found this to be interesting:</p>
  
  <p>"For this reason, styles and templates both define their own XAML namescopes, independent of whatever location in an object tree where the style or template is applied."</p>
  
  <p>if this is true, doesn't that mean that Binding ElementName should not work in templates at all?  But then I definitely have some working bindings on ElementName within my templates. That is the most confusing part, why do some bindings randomly work inside the templates and others do not?  It must have some method for trying to resolve the name even if it isn't in the template or same namescope</p>