Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can do it multiple way</p> <h2>first of all you could bind it directly</h2> <p><strong>XAML</strong></p> <pre><code>&lt;TextBox Visibility="{Binding myVisibility}"/&gt; </code></pre> <p><strong>VM Property</strong></p> <pre><code>public Visibility myVisibility { get { return Visibility.Hidden; } } </code></pre> <h2>but you could also use a Converter (the recommended way)</h2> <p><strong>XAML</strong></p> <pre><code> xmlns:local="clr-namespace:yourNamespace"&gt; &lt;Window.Resources&gt; &lt;local:BooleanToVisibilityConverter x:Key="BooleanToVisibility" /&gt; &lt;/Window.Resources&gt; &lt;TextBox Visibility="{Binding myVisibility,Converter={StaticResource BooleanToVisibility}}"/&gt; </code></pre> <p><strong>VM Property</strong></p> <pre><code>public bool myVisibility { get { return false; } } </code></pre> <p><strong>BooleanToVisibilityConverter.cs</strong></p> <pre><code>[ValueConversion(typeof(bool),typeof(Visibility))] public sealed class BooleanToVisibilityConverter : IValueConverter { public bool IsReversed { get; set; } public bool UseHidden { get; set; } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var val = System.Convert.ToBoolean(value, CultureInfo.InvariantCulture); if (this.IsReversed) { val = !val; } if (val) { return Visibility.Visible; } return this.UseHidden ? Visibility.Hidden : Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } </code></pre>
    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.
    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