tags:

views:

26

answers:

1

how to get the background of a control in the setter. Eg. How to the get the Background of TextBox in the Setter?

 <Setter TargetName="Border" Property="Background" Value="{TemplateBinding Background}"/>

This statement will give an error "Expression type is note valid style value". Is there any way to get the background property in the setter?

A: 

Try,

<Style TargetType={x:Type TextBox}>
  <Setter Property="Background" Value="Azure" />
</Style>

Is this what you are trying ??

Sudarsan Srinivasan

Update related to the first comment on this answer

If you want to do ElementBinding,

Sudarsan Srinivasan

sudarsanyes
The value is Azure.... i need to get the TextBox background
Kishore Kumar
Okay, now I understand. Why don't you try ElementBinding in here, Something like, Binding ElementName=<Name of the Element>, Path=Background ...What I am trying to suggest is you can bind a visual element's property to another element's property.
sudarsanyes