Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>One possible solution is to still use data binding on the IsExpanded property. </p> <p>Instead of binding to a boolean, bind to a list of booleans and use a ValueConverter to retrieve the appropriate item from the list.</p> <p>When creating all your expanders, give each one an index number, if you're not already. Then when you bind the IsExpanded property, set the Converter, and set the converter parameter to the index number of the expander. Then your converter will receive the list of boolean values as the 'value' argument and the index number as the 'parameter' argument and your converter can then return a boolean value.</p> <p>Your converter might look like this:</p> <pre><code>public class ListToBooleanConverter : IValueConverter { public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { if ((value != null) &amp; (parameter != null)) { try { Int16 itmNum = Convert.ToInt32(parameter); List&lt;bool&gt; lst = value; return lst[itmNum]; } catch (Exception ex) { return null; } } return null; } public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException("This method or operation is not implemented."); } } </code></pre> <p>In XAML, the implementation of this data binding and converter would look like this (for the expander with an index number of 5):</p> <pre><code>IsExpanded="{Binding Path=ListIsExpanded, Converter={StaticResource ListToBooleanConverter}, ConverterParameter=5}"&gt; </code></pre> <p>Obviously, in code, this implementation will look a little different.</p>
    singulars
    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.
    3. 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