Thomas.Benz
Thomas.Benz

Reputation: 8599

Property element and attribute tag syntax

I have a simple Label element and I code it in 2 ways.

Approach 1: I use attribute syntax for Converter attribute of Binding markup extension. The Converter attribute is in curly braces {}.

<Label Text="Flag Background" BackgroundColor="{Binding Source={x:Reference switch3}, Path=IsToggled, Converter={StaticResource boolToColor}}"></Label>

Approach 2: I use property-element tag for Converter attribute; It is OK.

<Label>
    <Label.Text>
      <Binding Source="{x:Reference switch3}" Path="IsToggled">
        <Binding.Converter>
          <toolkit:BoolToStringConverter FalseText="Red" TrueText="Lime"></toolkit:BoolToStringConverter>
        </Binding.Converter>
      </Binding>
    </Label.Text>

  </Label>

However, I cannot make Source as a property-element tag. I do not understand why I cannot use property-element tag for Source. Please explain.

<Label>
    <Label.Text>
      <Binding.Source>
          ...
      </Binding.Source>
    </Label.Text>

  </Label>

Upvotes: 0

Views: 327

Answers (1)

Evk
Evk

Reputation: 101563

You can, you just forgot binding itself:

<Label>
    <Label.Text>
        <Binding>
            <Binding.Source>...</Binding.Source>
        </Binding>
    </Label.Text>
</Label>

Upvotes: 2

Related Questions