tags:

views:

34

answers:

3

I have a 2 converter.

  1. Boolean to Visibility(Bool2Visible) - This converter convert Boolean value to Visibility enum
  2. Invert Boolean(InvertBool) - this converter invert Boolean value

My xaml is here

<stackpanel Name="A"
          visibility="{Binding isTrue,Converter={StaticResource Bool2Visible}}"/>
<stackpanel Name="B"
          visibility="{Binding isTrue,Converter={StaticResource Bool2Visible}}"/>

My goal is If isTrue=true, Stackpanel B will hidden. I need to use InsertBool and use Bool2Visible in Stackpanel B binding.

How to use 2 converter in one time.

Otherwise. newvalue=Bool2Visible(InsertBool(value))

If it is impossible, I can to create InvertAndConvertToVisibility converter.

A: 

I would rather use a special MultiValueConverter if you need to have a value determined from two seperate inputs!

rudigrobler
I know multivalueconverter. but i don't know how to use multivalueconverter in my reason
ebattulga
When using multiconverters you will have to write another class anyway. So this doesnt solve your issue...
klm_
+2  A: 

If it is impossible, i can to create InvertAndConvertToVisibility converter.

Personally i would just say to take this option, it is less than 5 minutes worth of work, and if you use a separate converter and name it appropriately it is obvious what you intend to happen.

An alternative is to modify your Bool2Visible converter use the parameter parameter to pass a flag which indicates that the operation should be negated.

slugster
I would use the parameter, will take even less than 5 minutes of work :) Just add ConverterParameter=False/True for the stackpanels and use bool invert = Convert.ToBoolean(parameter.ToString()) in the converter and you're good to go :-)
Meleak
That's a good idea
klm_
A: 

You can expand Bool2Visible converter with some logic that checks ConverterParameter. In the binding in 2nd StackPanel add ConverterParameter="invertValue" and inside converter class check the value of the parameter(ConverterParameter is automatically passed).

In that way you can handle your problem.

klm_