views:

8

answers:

1

Hi all,

I am trying to bind the value of a ConverterParameter. Currently finding it too tricky...

Codebehind

    public static readonly DependencyProperty RecognitionProperty = DependencyProperty.Register("RecognitionToEdit", typeof(Recognition), typeof(RecognitionInstancesWindow), null);

    public Recognition Recognition
    {
        get { return (Recognition)GetValue(RecognitionProperty); }
        set { SetValue(RecognitionProperty, value); }
    }

XAML of a TextBox, which forms part of a datatemplate for a coverflow type control.

<TextBlock HorizontalAlignment="Left" Margin="2,0,0,0" Text="{Binding Converter={StaticResource DateConverter}, Path=Date, ConverterParameter={Binding Recognition, Path=Frequency}}" />

Can anyone see where I'm going wrong please?

A: 

Unfortunately it is not possible, that's because for property to be bindable it should be dependency, and the object should be derived from DependencyObject. Binding is not derived from DependencyObject, so it is impossible, you should look another ways to do that

One way to do that is to create a class in static resource, and pass that class to your converter like this

<namespace:MyClass x:Key="MyClass">

<Binding ... ConvertParameter={StaticResource MyClass}/>

from MyClass you can return anything you want ;)

this post can be helpful

ArsenMkrt
Hmmm, OK. SO how else can I pass a parameter to my convertor at the time of binding?
Drammy
Silverlight by the way....
Drammy
see edited post
ArsenMkrt
Cheers so there's some food for thought. Should I be using a multi value converter, or can I not use them in Silverlight?
Drammy
The purpose of IMultiValueConverter is to implement converters that support multiple bindings,multiple bindings are not supported by silverlight yet ...
ArsenMkrt