none
Adding a value to a binding in code behind

    Question

  • Hi,

    I would like to add a given value (kind of an offset) to a multibinding I have.. This has to be done in code behind..

    How should I do this?

    Can I use another binding in the multibinding (but to a fixed value rather than a binding property)??

    Do you have another idea?

    thanks in advance...
    Friday, May 29, 2009 9:50 AM

Answers

  • If it's a fixed value, you can use the ConverterParameter property of your multibinding to pass your offset:

    <Multibinding Converter="{StaticResource MyConverter}" ConverterParameter="10">
    

    The property will end up in the parameter argument of your Convert and ConvertBack methods in your IMultiValueConverter
    • Marked as answer by RuiLopes Friday, May 29, 2009 3:05 PM
    Friday, May 29, 2009 12:17 PM
  • If it's a dynamic value, you can make a dependency property in the codebehind, and add a binding to that in your multibinding. Every time you update that property (your offset in this case) the multibinding converter will be hit and update appropriately.
    • Marked as answer by RuiLopes Friday, May 29, 2009 3:05 PM
    Friday, May 29, 2009 1:56 PM

All replies

  • If it's a fixed value, you can use the ConverterParameter property of your multibinding to pass your offset:

    <Multibinding Converter="{StaticResource MyConverter}" ConverterParameter="10">
    

    The property will end up in the parameter argument of your Convert and ConvertBack methods in your IMultiValueConverter
    • Marked as answer by RuiLopes Friday, May 29, 2009 3:05 PM
    Friday, May 29, 2009 12:17 PM
  • If it's a dynamic value, you can make a dependency property in the codebehind, and add a binding to that in your multibinding. Every time you update that property (your offset in this case) the multibinding converter will be hit and update appropriately.
    • Marked as answer by RuiLopes Friday, May 29, 2009 3:05 PM
    Friday, May 29, 2009 1:56 PM