Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's how I ended up solving this:</p> <ol> <li><p>As I thought initially, giving each item both a GroupID and a GroupName worked out pretty well. The IDs remained unique, but the groups were displayed as:</p> <pre><code> &lt;ListView.GroupStyle&gt; &lt;GroupStyle&gt; &lt;GroupStyle.ContainerStyle&gt; &lt;Style TargetType="{x:Type GroupItem}"&gt; &lt;Setter Property="Margin" Value="1,1,1,10"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type GroupItem}"&gt; &lt;Grid&gt; &lt;Rectangle Grid.ColumnSpan="4" Margin="0,0,0,0" Fill="{Binding Path=Items[0].GroupBackground}" Stroke="#FF808080" RadiusX="6" RadiusY="6" /&gt; &lt;Expander IsExpanded="True"&gt; &lt;Expander.Header&gt; &lt;DockPanel&gt; &lt;TextBlock FontSize="14" Text="{Binding Path=Items[0].GroupName}" Margin="5,0,0,0" HorizontalAlignment="Stretch"/&gt; &lt;/DockPanel&gt; &lt;/Expander.Header&gt; &lt;Expander.Content&gt; &lt;ItemsPresenter /&gt; &lt;/Expander.Content&gt; &lt;/Expander&gt; &lt;/Grid&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; </code></pre></li> <li><p>I found that the only styling I really needed to do on the group was the overall background color. I created another property on the items for use by the group. I accessed it with:</p> <pre><code>Fill="{Binding Path=Items[0].GroupBackground}" </code></pre></li> </ol> <p>Perhaps not the best approach (lots of duplication of the GroupName and GroupBackground data), but it worked for me.</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