wpfxaml

Can I add/subtract value that is bound to an element property?


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


Solution

  • 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}}"