michael
michael

Reputation: 15302

Is there any way to use a Wpf Label's Target without naming the target control?

Normally when you want to associate a Wpf Label with a target element you'd do the following:

<Label Target="{Binding ElementName=FirstName}" Content="First Name:" />
<TextBlock Name="FirstName" ... />

I was wondering if there is any other way to do this without using a Name or x:Name property?

Upvotes: 2

Views: 211

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564481

Using a named control and an ElementName binding is the standard approach to setting a label target.

The other approach would be to specifically set the Target property to a UIElement, which could be done in code behind for a generated UI, for example.

Upvotes: 2

Related Questions