How to add a ComboBox to a Listview?

Feb 7, 2015 at 5:40 PM
Edited Feb 8, 2015 at 9:23 AM
I am having a hard time trying to find out how to add a Combobox as a GridviewColumn

I have a collection of hashes $Items which works fine for all standard text columns. Each member of $Items looks like:

'Header1' => 'some value'
'Header2' => @(value, value 2)
ListView -ItemsSource $Items -View {
  GridView -Columns {
    GridviewColumn -Header 'Header1'
    GridviewColumn -Header 'Header2' -CellTemplate {
      Combobox -Name cbox | ConvertTo_DataTemplate
This code is very stripped down and eventually I need to bind some data but at the moment, I can't even get the ComboBox to display. If I try '-HeaderTemplate' instead, it seems to display. So, it seems that '-CellTemplate' is just ignored because the -'Header' property always outputs a default '-DisplayMemberBinding' in the XAML which, according to the MSDN docs, always overrides '-CellTemplate'.

Header 1 column is fine and populates from the $Items collection. The value for the 'Header2' key is an array with which I want to populate the ComboBox. I think I have tried every sort of binding declaration I can think of but I can't seem to even get the Combobox to display in the Header2 column. The best so far is just the string 'System.Object[]' appearing in the 'Header2' column.
Feb 8, 2015 at 8:01 PM
I found the solution: you have to set the '-DisplayMemberBinding' to an explicit '$Null' otherwise ShowUI will always insert a value, falling back to the value of '-Header' if it's not present.
Feb 9, 2015 at 2:33 PM

Hey, I'm glad you figured that out. I've been travelling, and saw this question but haven't had time to actually sit and help out.

I've was meaning to find some time when I got into the office this morning to dig up a ListView example, but it sounds like there's no need now :)

Feb 9, 2015 at 10:02 PM
I did fix this but I'm now stuck on trying to extend the comboboxes to
the width of the gridview, the same as here in XAML:

I can't find any examples of creating styles like this in showui. I
can't work out how to generate what -Setter needs in New-Style or how
to do this with -Resource and the ListView ...