I have two controls contained within a data template. Control #1 is a TextBlock known as "TXTBLOCK". Control #2 is a TextBox known as "TXTBOX":
TXTBLOCK has Visibility set to TextBox Visibility using the converter to give the opposite value.
Example:
<TextBlock Name="TXTBLOCK" Visibility="{Binding ElementName=**TXTBOX**, Path=Visibility, Converter={StaticResource toggleVisConverter}}" />
<TextBox Name="TXTBOX" Visibility="{Binding ElementName=**TXTBLOCK**, Path=Visibility, Converter={StaticResource toggleVisConverter}}" />
Converter is:
if (targetType == typeof(Visibility))
{
Visibility vis = (Visibility)value;
if (vis == Visibility.Collapsed)
{
return Visibility.Visible;
}
else
{
return Visibility.Collapsed;
}
//var vis == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;
}
//return vis;
throw new InvalidOperationException("Value must be of type 'Visibility'.");
Now...to me this should be simple. Changing the visibility of one will set the other's visibility to false.
Not the case...
Works the very first time through and then the converter stops being called.
Even if I explicitly state: "TXTBOX.Visibility = Visibility.Hidden" in code behind, the converter never gets called.
What gives? What am I missing?
This is my first post on SO...so forgive me if I missed something or need to provide more info. I'll be happy to do it
Thanks!