I'm trying to make a pair of TextBlock
s toggle (one Visible
, the other Collapsed
and vice-versa) on a bound boolean.
I could use BooleanToVisibilityConverter
for one but can't do a ! for the other so I'm trying to use MVVM Light's UniversalConverter
which takes a lambda in the ConverterParameter
.
Trouble is, I can't find any examples of the use and my attempts fail.
I've declared it in the XAML resources:
<Window.Resources>
<ex:UniversalConverter x:Key="UniversalConverter" />
</Window.Resources>
and then added this to the TextBlock
:
<TextBlock Visibility="{Binding Path=ShowA, Converter={StaticResource universalConverter}, ConverterParameter='b=>b?Visible:Collapsed'}">A</TextBlock>
<TextBlock Visibility="{Binding Path=ShowA, Converter={StaticResource universalConverter}, ConverterParameter='b=>b?Collapsed:Visible'}">B</TextBlock>
This throws an exception in the XAML design windows: Unknown identifier 'Visible'
.
I've also tried b=>b?Visibility.Visible:Visibility.Collapsed
which is an example in the UniversalConverter's Convert
method comment; that throws Unknown identifier 'Visibility'
.
How do I add the references needed to the UniversalConverter
?