views:

40

answers:

2

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. Can someone please let me know how to?

+1  A: 

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}" />
qntmfred
hmmm.. y didnt I think of that... will mark your answer as correct once I implement it.
Nitin Chaudhari
One problem, the code I am working on is currently using direct Model binding, and I cannot change from that Model to a ViewModel as it is being used at a lot of places :(
Nitin Chaudhari
A: 

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

Nitin Chaudhari