This project is read-only.

Binding to elements on any other page than first fails


When I try to bind something to an element on any other page than the first in the XAML tree, the binding fails with the message:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=<...>'. BindingExpression:Path=<...>; DataItem=<...>; target element is '<...>' (Name=''); target property is '<..>' (type 'Object')

This happens only at runtime, the binding works fine in design time.

  1. Create wizard with two pages
  2. Place two Label controls on the second page
  3. Give one Label a name
  4. Bind the Content property of the unnamed label to the Content property of the named label
  5. When running the binding failure will appear in output.
Example code attached

file attachments


SanderSaares wrote May 2, 2011 at 10:06 AM

I am also affected by this defect.

Workaround: apply the correct data context manually in the Initialize event handler.

DaHuntha wrote May 10, 2011 at 9:29 AM

My datacontext is a viewmodel. My current workaround is delegating the values trough the viewmodel.

PahanMenski wrote Feb 16, 2012 at 7:05 PM

This happens because only current page exists in logical and visual trees.
But yes, I think it would be useful to have all them. I'm going to add this as an option is the next version.

sexta13 wrote Sep 4, 2013 at 5:35 PM

Is this already in