By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,725 Members | 1,094 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,725 IT Pros & Developers. It's quick & easy.

WPF: Combobox as a header in gridview

P: n/a
Hi Guys

Started having a play with WPF and need some direction with a grid.

I am trying to build a list of products in a grid view with combox boxes as
column headers that allow filtering and sorting (similar to lists in excel).
Pic attached:

As a bonus, I would like the the columns to be able to be re-ordered at run

A column might contain Suppliers, so the Combobox would contain items like
the following:
All Suppliers
Sort Asc
Sort Desc

Selecting Supplier2 would filter the grid and show only those products for
that supplier.

I have been looking at the ColumnHeaderTemplate but have a way to go

Any guides greatly appreciated.


Start of some code below:
<DataTemplate x:Key="myHeaderTemplate">


<ComboBox ItemsSource="{Binding}" Width="100" />



<ListView ItemsSource="{Binding}" x:Name="lstStockItems" Grid.Row="1"
GridViewColumnHeader.Click="GridViewColumnHeaderCl ickedHandler">


<GridView AllowsColumnReorder="true" ColumnHeaderToolTip="Stock Items"
ColumnHeaderTemplate="{StaticResource myHeaderTemplate}">

<GridViewColumn DisplayMemberBinding=

"{Binding Path=StockItemID}"

Header="StockItemID" Width="100"/>

<GridViewColumn DisplayMemberBinding=

"{Binding Path=Name}"

Header="{Binding Path=Name}" Width="100"/>

<GridViewColumn DisplayMemberBinding=

"{Binding Path=SupplierName}"

Header="{Binding Path=SupplierName}" Width="100"/>

<GridViewColumn DisplayMemberBinding=

"{Binding Path=StockItemDepartmentName}"

Header="StockItemDepartmentName" Width="100"/>




<LinearGradientBrush EndPoint="0.418,0.009" StartPoint="0.42,1.7">

<GradientStop Color="#FF000000" Offset="0"/>

<GradientStop Color="#FF453F3F" Offset="0.545"/>

<GradientStop Color="#FF180404" Offset="1"/>




May 4 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.