开发者

Shorter Binding expression with validation

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 someon开发者_JS百科e tried this? Any other ideas how to make these repetetive bindings look better?


Your first suspicion is likely correct. A custom mark-up extension might be the best bet. I would check out this article.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜