Nitin Chaudhari
Nitin Chaudhari

Reputation: 1507

WPF correlating Multibindings and Converter's values[]

My XAML is as follows

<Button.IsEnabled >
    <MultiBinding Converter="{StaticResource IsEnabledConverter}" >
        <Binding Path="aaa"/>
        <Binding Path="bbb"/>
        <Binding Path="ccc"/>
        <Binding Path="ddd"/>
        <Binding Path="eee"/>
        <Binding Path="fff"/>
        <Binding Path="ggg"/>
        <Binding Path="hhh"/>
        <Binding Path="iii"/>
        <Binding Path="jjj"/>
    </MultiBinding>
</Button.IsEnabled>

Now in my Convert function i get 10 values and its a headache to keep the binding sequence and index number of values collection in sync. There has to be a better way to connect these two. How to?

Upvotes: 2

Views: 733

Answers (2)

Nitin Chaudhari
Nitin Chaudhari

Reputation: 1507

Although having View-Model would be a better way, for those who are not using view-model, or cannot modify existing view-model, check out my post : http://technologyandme.blogspot.com/2010/07/wpf-converter-values.html

Upvotes: 0

kenwarner
kenwarner

Reputation: 29120

Instead of using a converter at all, bind it to a property in your viewmodel that does the conversion

public bool IsEnabled
{
    get
    {
        return (aaa || bbb || ccc || ddd || eee) 
               && fff && ggg && hhh && iii && jjj;
    }
}

 

<Button IsEnabled="{Binding Path=IsEnabled}" />

Upvotes: 2

Related Questions