0

Im learning validations in WPF and got one question, when I want to check in XAML if any control has any errors and unblock smth if so then I can write for example something like this code snippet:

<DataTrigger Binding="{Binding ElementName=tx2, Path=(Validation.HasError)}" Value="false">
      <Setter Property="IsEnabled" Value="True"/>
</DataTrigger>

What interest me is the part :

   Path=(Validation.HasError)

Why do I have to put this in brackets? When I bind for example :

 <TextBlock Text={Binding ElementName=myTextBlock, Path=Text.Length}/>

I dont need brackets but Im also using the smth.smth syntax, then why Validation.HasError mut be in "( )" ?

CSharpBeginner
  • 1,625
  • 5
  • 22
  • 36
  • 3
    Attached dependency properties need to have `()` to be bound – Charleh Jul 21 '14 at 21:22
  • http://msdn.microsoft.com/en-us/library/ms749011(v=vs.110).aspx see here – Charleh Jul 21 '14 at 21:22
  • Info about binding syntax here http://msdn.microsoft.com/en-gb/library/cc645024(v=vs.95).aspx#attacheddata – Charleh Jul 21 '14 at 21:24
  • 1
    @Charleh: Why the heck don't you post that as an answer? – H.B. Jul 21 '14 at 21:38
  • Because it probably needs to be marked a dupe but I'm too lazy to search for a dupe :) – Charleh Jul 21 '14 at 21:45
  • @Charleh: Here's one then: http://stackoverflow.com/questions/14382581/wpf-syntax-what-parentheses-means (Also: You should use @-notation if you want comments in someone else's post reach another's inbox) – H.B. Jul 21 '14 at 22:23

0 Answers0