Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I wouldn't recommend setting the height of controls to zero - for one thing, it would still be possible to tab to a 0-height control which would be confusing for users to say the least :)</p> <p>As an alternative, try binding the visibility of any affected controls to the combobox selection, e.g:</p> <pre><code>&lt;UserControl xmlns:cnv="clr-namespace:your_namespace_here"&gt; &lt;Grid Margin="5"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;RowDefinition Height="Auto" /&gt; &lt;/Grid.RowDefinitions&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="150" /&gt; &lt;ColumnDefinition Width="*" /&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Label Grid.Row="0" Grid.Column="0" Content="Label1:" /&gt; &lt;ListBox Grid.Row="0" Grid.Column="1" /&gt; &lt;Label Grid.Row="1" Grid.Column="0" Content="Label2:" /&gt; &lt;ComboBox Name="cbo" Grid.Row="1" Grid.Column="1" /&gt; &lt;Label Grid.Row="2" Grid.Column="0" Content="Label3:" Visibility="{Binding ElementName=cbo, Path=SelectedIndex, Converter={cnv:IntToVisibilityConverter}}" /&gt; &lt;TextBox Grid.Row="2" Grid.Column="1" /&gt; &lt;/Grid&gt; </code></pre> <p></p> <p>In code, put together a converter which returns the relevant Visibility type:</p> <pre><code>namespace your_namespace_here { public class IntToVisibilityConverter : MarkupExtension, IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { int _value = (int)value; return (_value &gt; 0) ? Visibility.Visible : Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } #endregion public override object ProvideValue(IServiceProvider serviceProvider) { return this; } } } </code></pre> <p>Note that in this example, the converter will return Visiblity.Collapsed if the first item in the combo is selected, otherwise Visiblity.Visible.</p> <p>Untested code, but the method is sound. Hope this is of some use!</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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