Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to save the IsExpanded state in group headers of a listview - Take 2
    text
    copied!<p>To get some context this question refers to <a href="https://stackoverflow.com/questions/2808777/how-to-save-the-isexpanded-state-in-group-headers-of-a-listview/12343338#12343338">How to save the IsExpanded state in group headers of a listview</a></p> <p>What am I missing here?</p> <p>When I try to do what is suggested in the referenced post I get: </p> <p><strong>BindingExpression path error: '[]' property not found on 'object' ''ExpandStateManager'</strong></p> <p><strong>My ExpandStateManager</strong></p> <pre><code>public class ExpandStateManager { Dictionary&lt;Category, bool&gt; expandStates = new Dictionary&lt;Category, bool&gt;(); public bool this[Category key] { get { if (!expandStates.ContainsKey(key)) return false; return expandStates[key]; } set { expandStates[key] = value; } } } </code></pre> <p><strong>XAML</strong></p> <pre><code> &lt;ListView ItemsSource="{Binding Source={StaticResource cvs}}" ItemTemplate="{StaticResource animalTemplate}" Width="200"&gt; &lt;ListView.GroupStyle&gt; &lt;GroupStyle&gt; &lt;GroupStyle.ContainerStyle&gt; &lt;Style TargetType="{x:Type GroupItem}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type GroupItem}"&gt; &lt;Expander IsExpanded="{Binding Source={StaticResource ExpandStateManger}, Path=[Items[0].ObjectType]}"&gt; &lt;Expander.Header&gt; &lt;DockPanel&gt; &lt;TextBlock Text="{Binding Name}" /&gt; &lt;/DockPanel&gt; &lt;/Expander.Header&gt; &lt;Expander.Content&gt; &lt;ItemsPresenter /&gt; &lt;/Expander.Content&gt; &lt;/Expander&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/GroupStyle.ContainerStyle&gt; &lt;/GroupStyle&gt; &lt;/ListView.GroupStyle&gt; &lt;/ListView&gt; </code></pre>
 

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