Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Why doesn't Textbox support Multibinding on IsEnabled?

$
0
0

Hi all,

I have searched far and wide, but I can't find an answer to what should be a simple question....

Given that I have a converter with this signature:

 
public class multiBoolConverter : IMultiValueConverter
	{
		public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) 
{
...
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
return null;
}

I am trying to implement a textbox that is bound to a value and has it's IsEnabled property bound to 2 values using the above multiConverter.

I have found tons of examples, but none that work with this situation (or at least close enough that I can figure it out.)

Here is the basic textbox:

<TextBox Text = "{Binding thing_no}"><Textbox.IsEnabled><MultiBinding Converter="{StaticResource multiBoolConverter}"
            ConverterParameter="and"><Binding Path="val1" /><Binding Path="val2"/></MultiBinding></Textbox.IsEnabled></TextBox>

And in the resource section of the xaml form I have:

<src:multiBoolConverter x:Key="multiBoolConverter" />

Where src: is tied to the namespace that holds the convert class defined above.

The problem is that when I try this, I get an error that "The attachable property 'IsEnabled' was not found in type 'TextBox'.

Now we all know that Textbox does support IsEnabled (I use it a bunch of other places).  But in this one case, I need to look at 2 bool values in the model, whereas in all the other cases, I just need one.

So the converter code looks at the 2 values and returns true/false.  I pass a parameter so I can specify if I need the values to be compared with an AND or OR.

Any idea what silly little thing I am missing that is causing it not to behave?

Thanks!


me (and yes, I DO mark correct answers)


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>