Questions tagged [relativesource]

130 questions
657
votes
14 answers

How do I use WPF bindings with RelativeSource?

How do I use RelativeSource with WPF bindings and what are the different use-cases?
David Schmitt
  • 58,259
  • 26
  • 121
  • 165
180
votes
6 answers

WPF TemplateBinding vs RelativeSource TemplatedParent

What is the difference between these 2 bindings: and
theSpyCry
  • 12,073
  • 28
  • 96
  • 152
36
votes
4 answers

RelativeSource binding from a ToolTip or ContextMenu

What am I doing wrong here?:
27
votes
1 answer

WPF pass parent binding object to the converter

I have ItemsControl that is bound to collection of type Student. Inside the ItemTemplate I have a TextBox that uses IValueConverter to do some custom calculations and logic. I want to pass the actual Student object to the value converter, instead a…
Tomislav Markovski
  • 12,331
  • 7
  • 50
  • 72
23
votes
4 answers

What exactly does WPF Data Binding's "RelativeSource FindAncestor" do?

I am currently working within a WPF user control (the root element of my XAML file is "UserControl"), which I know is being hosted inside a Window. How can I access a property of the Window using data binding? Does anyone know why simply
user200783
  • 13,722
  • 12
  • 69
  • 135
21
votes
4 answers

Silverlight 4 RelativeSource FindAncestor binding

Will there be RelativeSource FindAncestor, AncestorType... in Silverlight 4?
David
  • 233
  • 1
  • 2
  • 5
20
votes
3 answers

ElementName vs. RelativeResource?

What of the following TextBlocks' Bindings costs more performance:
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
15
votes
2 answers

WPF Bind to parent property from within nested element using style

I've been trying to build a text box with a hint that's displaying while it's empty. I'm having trouble setting the hint text from within a style. To be precise, this works (that is, it binds correctly):
veljkoz
  • 8,384
  • 8
  • 55
  • 91
13
votes
3 answers

Differences between ElementName="" and RelativeSource self?

What are the differences between making a binding self-referential via name versus self-referential via RelativeSource? For example:
Greg D
  • 43,259
  • 14
  • 84
  • 117
12
votes
1 answer

WPF - RelativeSource in Style

My target is to bind the Content-Property of the Label to the Tag-Property of the Elements the Style is applied to. But my solution doesn't seem to work: My style: