Original: One control in WPF binds another control's properties
Like a button in a grid responds differently depending on whether another button is displayed:
Specify the control by ElementName when binding
<grid margin= "50,130" >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<columndefinition width= "/>"
</Grid.ColumnDefinitions>
<button content= "ASDFASDFADSFA" background= "Aquamarine" >
<Button.Style>
<style targettype= "{x:type button}" >
<setter property= "Template" >
<Setter.Value>
<controltemplate targettype= "{x:type button}" >
<border x:name= "BD" borderbrush= "Black" background= "{TemplateBinding Background}" borderthickness= "1" cornerradius= "6,0,0,6" >
<textblock verticalalignment= "center" horizontalalignment= "center" text= "{TemplateBinding Content}"/>
</Border>
<ControlTemplate.Triggers>
<datatrigger binding= "{Bindingelementname=btn2, path=visibility} "value=" collapsed ">
<setter targetname= "BD" property= "Cornerradius" value= "6,6,6,6"/>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>
<button x:name= "btn2" grid.column= "2" command= "{Binding Maincommand}" background= "Beige" >
<Button.Style>
<style targettype= "{x:type button}" >
<setter property= "Template" >
<Setter.Value>
<controltemplate targettype= "{x:type button}" >
<border borderbrush= "Black" background= "{TemplateBinding Background}" borderthickness= "0,1,1,1" cornerradius= " 0,6,6,0 ">
<path data= "M 0,0 l 20,0 L 10,10 Z" fill= "Black" verticalalignment= "center" horizontalalignment= "center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>
</Grid>
One control in WPF binds another control's properties