Can I add/subtract value that is bound to an eleme

2020-08-25 06:02发布

问题:

Does XAML allows modification of bound value?
Like Width="{Binding Elementname="lstMine", Path=Width}" -100 ? So that I can have a relative value.

回答1:

You can use converters for this purpose, and my WPF Converters library includes an ExpressionConverter that allows you to do exactly that:

Width="{Binding Width, ElementName=lstMine, Converter={con:ExpressionConverter {}{0}-100}}"


回答2:

use Converter for these purpose



标签: wpf xaml