ModS
ModS

Reputation: 846

Binding c# Property to a different Property on the SAME control

Good Morning, I need to make the label below to where the Tag property will be the same as the content.
Basically If the content is "this label's content" then the Tag property should be "this label's content" as well.
I have tried quite a few things however this is my most recent attempt:

 <Label x:Name="label" HorizontalContentAlignment="Center" Background="{Binding Background, ElementName=ColorForBGG}" Tag="{Binding RelativeSource={RelativeSource Self}, Path=x.Content}"/>

Upvotes: 0

Views: 196

Answers (1)

Rohit Prakash
Rohit Prakash

Reputation: 1972

you can do this directly using the Element-

<Label x:Name="label" Content="Label" HorizontalContentAlignment="Center" Background="{Binding Background, ElementName=ColorForBGG}" Margin="62,59,0,0" VerticalAlignment="Top" Tag="{Binding Content, ElementName=label}"/>

Upvotes: 1

Related Questions