RelativeSource binding doesn't work.
-
2012년 3월 12일 월요일 오후 3:54
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.<Style TargetType="local:Calendar"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="local:Calendar"> ... <Grid> ... <TextBlock Grid.Column="1" Text="{Binding Path=Namer,RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" /> <TextBlock Grid.Column="2" Text="{TemplateBinding Namer}" /> ... </Style>
모든 응답
-
2012년 3월 13일 화요일 오후 2:12중재자
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.

-
2012년 4월 14일 토요일 오후 1:42
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.
thanks.
Sergey
-
2012년 5월 6일 일요일 오후 7:35
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.
notacat
-
2012년 5월 6일 일요일 오후 8:31I 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.
lh
-
2012년 5월 8일 화요일 오후 9:06
I posted this issue to MS connect : https://connect.microsoft.com/VisualStudio/feedback/details/741181/relativesource-templatedparent-binding-doesnt-work-in-metro-applications. Please, vote for it.
notacat

