WPF: Combobox as a header in gridview

E

ER

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:
http://www.ozgrid.com/images/Pictures/Filterswitches&Dropdown.jpg

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

A column might contain Suppliers, so the Combobox would contain items like
the following:
All Suppliers
--
Sort Asc
Sort Desc
--
Supplier1
Supplier2
Supplier3
etc

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.

ER

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

<DockPanel>

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

</DockPanel>

</DataTemplate>



<ListView ItemsSource="{Binding}" x:Name="lstStockItems" Grid.Row="1"
Foreground="#FFFFFFFF"
GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler">

<ListView.View>

<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"/>

</GridView>

</ListView.View>

<ListView.Background>

<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"/>

</LinearGradientBrush>

</ListView.Background>

</ListView>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top