RelativeSource binding doesn't work.


  • I'm not sure why RelativeSource binding is not working, but the TemplateBinding is working.
    I'm just using the Namer dependency property as a test. It is of type string.
    Reading the docs, the RelativeSource TemplatedParent is basically the same as TemplateBinding, so it SHOULD work.

                                        Text="{Binding Path=Namer,RelativeSource={RelativeSource TemplatedParent},
                                        Mode=TwoWay}" />
                                        Text="{TemplateBinding Namer}" />

    Monday, March 12, 2012 3:54 PM

All replies

  • Hi,

    Please first check the sample XAML data binding sample.

    Meanwhile, please read through Data binding with XAML for more details.

    Otherwise, please share more snippets for investigation.

    Best wishes,

    Robin [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 13, 2012 2:12 PM
  • I think it is a bug, as I ran into the same issue.  I had to change my code to use template binding instead.  I wish the option was removed since it does not work.



    Saturday, April 14, 2012 1:42 PM
  • it looks like a bug. I can reproduce it. I've found 2 workarounds:

    - use TemplateBinding

    - if you need ValueConverter, the TemplateBinding won't work. In such case you'll have to set DataContext to the owning control in code. I.e. somewhere in your Calendar control write DataContext = this;. Then, remove RelatedSource part from your xaml.

    I believe that it must be fixed by MS, or at least they must document all binding-related changes.


    Sunday, May 06, 2012 7:35 PM
  • I noticed it´s not working in ControlTemplates of custom controls in ShareTargets. If the same control is hosted on a UserControl inside the application and is binding to the same Model in xaml, it is working…. I also would consider this a bug.


    Sunday, May 06, 2012 8:31 PM