Note that there are some explanatory texts on larger screens.

plurals
  1. PObinding control visibility to a toggle button's ischecked property
    primarykey
    data
    text
    <p><strong>EDIT</strong>: it appears this was just VisualStudio somehow getting confused. It accepted it just fine after restarting. I'm not seeing a way to close the question though.</p> <p>I have a window with two controls: a togglebutton and a textbox. I want the togglebutton to control the visibility of the textbox, namely, show the textbox when the togglebutton's ischecked property is true, and collapse the textbox when it is false (with an initial ischecked status of false).</p> <p>Based on the information I've been able to find, it seems like the following simple XAML should work:</p> <pre><code>&lt;Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;Window.Resources&gt; &lt;BooleanToVisibilityConverter x:Key="IsCheckedVisibilityConverter"/&gt; &lt;/Window.Resources&gt; &lt;StackPanel&gt; &lt;ToggleButton x:Name="ShowTextBox" Content="Show the TextBox" IsChecked="False"/&gt; &lt;TextBox Visibility="{Binding IsChecked, ElementName=ShowTextBox, Converter={StaticResource IsCheckedVisibilityConverter}}"/&gt; &lt;/StackPanel&gt; &lt;/Window&gt; </code></pre> <p>However, I am unable to compile and run this as I receive the error:</p> <pre><code>The TypeConverter for "IValueConverter" does not support converting from a string. </code></pre> <p>with a blue squiqqly underline underneath the portion [Visibility="{Binding].</p> <p>I'm sure I must be doing something wrong, but I've spent a few hours trying to find information as to why it's not working, and all I can find are examples showing this being the more-or-less correct way to do it. Can anyone point out what I'm doing wrong?</p> <p>I'm relatively new to C#/WPF/XAML, so I'm toying around with things to get a better feel for it all. If there's a control that's better suited for this task, I'm interested to know about it, but I'm more interested in how to get this working so I can better understand what's happening (or rather, why it's not working).</p> <p>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload