Questions tagged [templatebinding]

141 questions
180
votes
6 answers

WPF TemplateBinding vs RelativeSource TemplatedParent

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

In WPF, why doesn't TemplateBinding work where Binding does?

Ok... this is leaving me scratching my head. I have two WPF controls--one's a user control and the other's a custom control. Let's call them UserFoo and CustomFoo. In the control template for CustomFoo, I use an instance of UserFoo which is a…
Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
36
votes
4 answers

WPF ControlTemplate: How to provide a default value for TemplateBinding?

I am writing a WPF control that subclasses a Button. I then provide a default style in Themes\generic.xaml, that looks like this (simplified): ...but I get the error: 'Padding' member is not valid…
devuxer
  • 41,681
  • 47
  • 180
  • 292
22
votes
4 answers

Template Binding in Control template

I have the following control template. I wish to set the source property for the image control in the control template using Template Binding. But since this is a control template for button control and the button control doesn't have source…
Sam
  • 223
  • 1
  • 2
  • 5
18
votes
1 answer

Is it possible to use a converter on a TemplateBinding in XAML?

I am building a button style that relies on converting a colour brush to a darker shade to create a shadow. In regular XAML I have a converter than I use on the binding that works perfectly: BorderBrush="{Binding Background,…
pumpkinszwan
  • 1,312
  • 11
  • 21
15
votes
2 answers

How to use template binding inside data template in custom control (Silverlight)

I am trying to create control which will take ItemsSource and InnerTemplate and will show all the items wrapped in CheckBoxes. The control has 2 dependency properties: public static readonly DependencyProperty ItemsSourceProperty =…
stefando
  • 495
  • 1
  • 7
  • 13
14
votes
1 answer

Use a MultiBinding with TemplateBindings

I am making a custom control in WPF. I am still learning the ins-and-outs of what a TemplateBinding is (used a lot in custom controls). One think I am noticing is that I can't seem to use a TemplateBinding inside of a MulitBinding. When I try…
Vaccano
  • 78,325
  • 149
  • 468
  • 850
10
votes
2 answers

How to TemplateBind to BorderThickness.Top (or Bottom or Left or Right)?

I wonder if it is possible to bind a structure element like BorderThickness.Top to TemplatedParent's corresponding property. I have tried
mg007
  • 2,888
  • 24
  • 29
9
votes
2 answers

Update source with TemplateBinding

I use this style for all my labels