Shorter Binding expression with validation

Posted by Andrii V on Stack Overflow See other posts from Stack Overflow or by Andrii V
Published on 2010-06-03T21:34:06Z Indexed on 2010/06/03 21:54 UTC
Read the original article Hit count: 295

Filed under:
|
|

Hi, I'm repeating same binding parameters for every textbox and they're quite long strings (which is not good for many reasons). And I'm wondering if there's a way to make them shorter?

For instance all my controls on forms are using the following binding template:

Text="{Binding SourceProperty, UpdateSourceTrigger=PropertyChanged, 
ValidatesOnExceptions=True, ValidatesOnDataErrors=True, 
NotifyOnValidationError=True}"

I'd would like to have something shorter that ideally will take SourceProperty as parameter. Possbly like this:

Text="{MyBinding SourceProperty}"

or

Text="{Binding SourceProperty, Params=MyParams}"

One possible option would be to inherit from Binding and create new markup extension. Did someone tried this? Any other ideas how to make these repetetive bindings look better?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about wpf