Note that there are some explanatory texts on larger screens.

plurals
  1. POListView with nested Expander not collapsing
    text
    copied!<p>This question is the same as this other <a href="https://stackoverflow.com/questions/1381336/cant-get-wpf-listview-to-collapse-when-expanders-in-the-listview-collapse">unanswered question</a>.</p> <p>When the <em>Expander</em> is expanded the outer <em>ListView</em> grows to make space for the expanders contents, but when the <em>Expander</em> is then collapsed the view does not force the ListView to resize.</p> <p>Reduced code, with notes after:</p> <pre><code>&lt;!--&lt;StackPanel&gt;--&gt; &lt;ItemsControl&gt; &lt;!-- ParameterGroupView --&gt; &lt;Border BorderBrush="Brown" BorderThickness="1" CornerRadius="4" Padding="4"&gt; &lt;ListView HorizontalContentAlignment="Stretch"&gt; &lt;Expander Header="Expander A" IsExpanded="False"&gt; &lt;ListView HorizontalContentAlignment="Stretch"&gt; &lt;!-- TextView --&gt; &lt;TextBlock &gt;Content A&lt;/TextBlock&gt; &lt;TextBlock &gt;Content B&lt;/TextBlock&gt; &lt;/ListView&gt; &lt;/Expander&gt; &lt;/ListView&gt; &lt;/Border&gt; &lt;/ItemsControl&gt; &lt;!--&lt;/StackPanel&gt;--&gt; </code></pre> <p>I have the <em>ParameterGroupView</em> in a <em>ItemsControl</em> or <em>StackPanel</em> because there is actually many <em>ParameterGroupView</em> entries. Swapping to a <em>StackPanel</em> does not change the behaviour.</p> <p>Removing the <em>Boarder</em> does not affect the behaviour, but having it helps show the behaviour with only a single <em>ParameterGroupView</em>.</p> <p>There can be many <em>Expander</em> sections in the outer <em>ListView</em>, and the <em>Expander</em> can have many entities inside the inner <em>ListView</em>.</p> <p>The outer <em>ListView</em> and <em>Expander</em> is to replace a <em>TreeView</em>, that was used to have a list of collapsible nodes, but the <em>TreeView</em>'s internal use of grids, means the TextView items were squashed horizonatlly, the same as if you remove ether <em>HorizontalContentAlignment="Stretch"</em> attributes.</p> <p>So if there is another way to wrap/wire all this up, I'll be also happy. </p> <p>This is a problem because our <em>TextView</em> blocks are large and there are many <em>Expander</em>s.</p> <p>Edit: <em>TextView</em> is used as the code is data-bound, and thus dynamically put together. So any replacement for ListView would need some form of <em>ItemsSource</em> </p>
 

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