I need a simple example of Grouping List View ItemsI'm very good at making winforms applicaitons.  I decided to start learning WPF so that I could run my applications in a web page or as a stand alone app.  The problem is that I'm having a lot of trouble getting up to speed.  I'm trying to make a user control that displays a particular object in groups.  Kind of like a winform ListView.  Everything was going great until I tried to group items.  Now I'm stuck.  Here's my XAML<br/><br/> <div style="background-color:white;color:black"> <pre><span style="color:blue">&lt;</span><span style="color:#a31515">UserControl</span> <span style="color:red">x:Class</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">CarList</span><span style="color:black">&quot;</span> <span style="color:red">xmlns</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span><span style="color:black">&quot;</span> <span style="color:red">xmlns:x</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">http://schemas.microsoft.com/winfx/2006/xaml</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">ListView</span> <span style="color:red">Name</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">_uxCarList</span><span style="color:black">&quot;</span> <span style="color:red">MouseDoubleClick</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">_uxCarList_MouseDoubleClick</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">CollectionViewSource</span> <span style="color:red">Source</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">{Binding}</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">CollectionViewSource.GroupDescriptions</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">PropertyGroupDescription</span> <span style="color:red">PropertyName</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">Make</span><span style="color:black">&quot;</span> <span style="color:blue">/&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">CollectionViewSource.GroupDescriptions</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">CollectionViewSource</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">ListView.View</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">GridView</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">GridViewColumn</span> <span style="color:red">Header</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">Make</span><span style="color:black">&quot;</span> <span style="color:red">DisplayMemberBinding</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">{Binding Path=Make}</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span><span style="color:blue">&lt;/</span><span style="color:#a31515">GridViewColumn</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">GridViewColumn</span> <span style="color:red">Header</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">Model</span><span style="color:black">&quot;</span> <span style="color:red">DisplayMemberBinding</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">{Binding Path=Model}</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span><span style="color:blue">&lt;/</span><span style="color:#a31515">GridViewColumn</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">GridViewColumn</span> <span style="color:red">Header</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">Color</span><span style="color:black">&quot;</span> <span style="color:red">DisplayMemberBinding</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">{Binding Path=Color}</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span><span style="color:blue">&lt;/</span><span style="color:#a31515">GridViewColumn</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">GridView</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">ListView.View</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">ListView</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">UserControl</span><span style="color:blue">&gt;</span> </pre> </div> So inside my code behind I define a list of Cars (List&lt;Cars&gt;) and have a function that populates the listview.  The cars show up, but the groups don't.  <br/><br/>I'm frustrated by how unintuitive WPF is.  Everything from the events to the XAML feels convoluted to me.  Where are the bare minimum examples? I don't want to know how to add groups from an XML document while doing the hokey pokey and making it into some expandable widget.  I want to know where examples are that say: Here's your object list.  Here's how to get them to show up in your list view with simple groups.  From there I can build up to all of the fancy stuff, but I'm desperate to learn the basics first.  Please help.© 2009 Microsoft Corporation. All rights reserved.Fri, 10 Jul 2009 11:48:36 Z0ac27204-0b98-4259-8782-4323038d8108http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0ac27204-0b98-4259-8782-4323038d8108#0ac27204-0b98-4259-8782-4323038d8108http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0ac27204-0b98-4259-8782-4323038d8108#0ac27204-0b98-4259-8782-4323038d8108GameboyHippohttp://social.msdn.microsoft.com/Profile/en-US/?user=GameboyHippoI need a simple example of Grouping List View ItemsI'm very good at making winforms applicaitons.  I decided to start learning WPF so that I could run my applications in a web page or as a stand alone app.  The problem is that I'm having a lot of trouble getting up to speed.  I'm trying to make a user control that displays a particular object in groups.  Kind of like a winform ListView.  Everything was going great until I tried to group items.  Now I'm stuck.  Here's my XAML<br/><br/> <div style="background-color:white;color:black"> <pre><span style="color:blue">&lt;</span><span style="color:#a31515">UserControl</span> <span style="color:red">x:Class</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">CarList</span><span style="color:black">&quot;</span> <span style="color:red">xmlns</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span><span style="color:black">&quot;</span> <span style="color:red">xmlns:x</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">http://schemas.microsoft.com/winfx/2006/xaml</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">ListView</span> <span style="color:red">Name</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">_uxCarList</span><span style="color:black">&quot;</span> <span style="color:red">MouseDoubleClick</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">_uxCarList_MouseDoubleClick</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">CollectionViewSource</span> <span style="color:red">Source</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">{Binding}</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">CollectionViewSource.GroupDescriptions</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">PropertyGroupDescription</span> <span style="color:red">PropertyName</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">Make</span><span style="color:black">&quot;</span> <span style="color:blue">/&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">CollectionViewSource.GroupDescriptions</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">CollectionViewSource</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">ListView.View</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">GridView</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">GridViewColumn</span> <span style="color:red">Header</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">Make</span><span style="color:black">&quot;</span> <span style="color:red">DisplayMemberBinding</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">{Binding Path=Make}</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span><span style="color:blue">&lt;/</span><span style="color:#a31515">GridViewColumn</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">GridViewColumn</span> <span style="color:red">Header</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">Model</span><span style="color:black">&quot;</span> <span style="color:red">DisplayMemberBinding</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">{Binding Path=Model}</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span><span style="color:blue">&lt;/</span><span style="color:#a31515">GridViewColumn</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;</span><span style="color:#a31515">GridViewColumn</span> <span style="color:red">Header</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">Color</span><span style="color:black">&quot;</span> <span style="color:red">DisplayMemberBinding</span><span style="color:blue">=</span><span style="color:black">&quot;</span><span style="color:blue">{Binding Path=Color}</span><span style="color:black">&quot;</span><span style="color:blue">&gt;</span><span style="color:blue">&lt;/</span><span style="color:#a31515">GridViewColumn</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">GridView</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">ListView.View</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">ListView</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:blue">&gt;</span> <span style="color:blue">&lt;/</span><span style="color:#a31515">UserControl</span><span style="color:blue">&gt;</span> </pre> </div> So inside my code behind I define a list of Cars (List&lt;Cars&gt;) and have a function that populates the listview.  The cars show up, but the groups don't.  <br/><br/>I'm frustrated by how unintuitive WPF is.  Everything from the events to the XAML feels convoluted to me.  Where are the bare minimum examples? I don't want to know how to add groups from an XML document while doing the hokey pokey and making it into some expandable widget.  I want to know where examples are that say: Here's your object list.  Here's how to get them to show up in your list view with simple groups.  From there I can build up to all of the fancy stuff, but I'm desperate to learn the basics first.  Please help.Sat, 04 Jul 2009 17:54:05 Z2009-07-04T17:55:13Zhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0ac27204-0b98-4259-8782-4323038d8108#85698ad3-0070-46ec-83ac-f7178d12f59bhttp://social.msdn.microsoft.com/Forums/en-US/wpf/thread/0ac27204-0b98-4259-8782-4323038d8108#85698ad3-0070-46ec-83ac-f7178d12f59bMariano O. Rodriguezhttp://social.msdn.microsoft.com/Profile/en-US/?user=Mariano%20O.%20RodriguezI need a simple example of Grouping List View ItemsThat is why you didn't define any template to show the groups, for example tou can add the default template that just show the text of the group:<br/><br/> <pre lang=x-xml>&lt;ListView.GroupStyle&gt; &lt;x:Static Member=&quot;GroupStyle.Default&quot;/&gt; &lt;/ListView.GroupStyle&gt;</pre> The CollectionViewSource should be defined as a resource:<br/><br/> <pre lang=x-xml>&lt;UserControl.Resources&gt; &lt;CollectionViewSource x:Key=&quot;MyList&quot; Source=&quot;{Binding}&quot;&gt; &lt;CollectionViewSource.GroupDescriptions&gt; &lt;PropertyGroupDescription PropertyName=&quot;Make&quot; /&gt; &lt;/CollectionViewSource.GroupDescriptions&gt; &lt;/CollectionViewSource&gt; </pre> <br/>And finally you should bind the list with the CollectionViewSource:<br/><br/> <pre>&lt;ListView Name=&quot;_uxCarList&quot; MouseDoubleClick=&quot;_uxCarList_MouseDoubleClick&quot; ItemsSource=&quot;{Binding Source={StaticResource MyList}}&quot;&gt; </pre> <br/>You have a complete example of grouping in this blog <a href="http://bea.stollnitz.com/blog/?p=19">http://bea.stollnitz.com/blog/?p=19</a><br/><br/><br/><hr class="sig">http://weblogs.asp.net/marianor/Sat, 04 Jul 2009 18:18:45 Z2009-07-04T18:18:45Z