Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

What does [0] means in "{Binding [0].ErrorContent}"?

$
0
0

Hi there:

I'm studying validation and I ran across this xaml code:

<TextBox x:Name="AddressBox"><TextBox.Text><Binding ElementName="This" Path="IPAddress" UpdateSourceTrigger="PropertyChanged"><Binding.ValidationRules><local:IPv4ValidationRule /></Binding.ValidationRules></Binding></TextBox.Text><Validation.ErrorTemplate><ControlTemplate><StackPanel><!-- Placeholder for the TextBox itself --><AdornedElementPlaceholder x:Name="textBox"/><TextBlock Text="{Binding [0].ErrorContent}" Foreground="Red"/></StackPanel></ControlTemplate></Validation.ErrorTemplate></TextBox>

The TextBlock used to show errors has it's Text property bound to [0].ErrorContent, why the use of [0] instead of the identifier for some collection, I guess it's Validation.Errors or something, in this case, why not using something like Validation.Errors[0].ErrorContent, and why wpf allows indexing a non identified property?

Rafael


Believe you can do it, and you will!!




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>