开发者

How to bind a ConvertorParameter

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?


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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜