Multi-Column Items with Headers in WPF Combobox
I would like to have a combobox that displays items with multiple properties showing per item with a column header for the property. Here is the control template I'm currently working with. What is the best way to go about adding column headers to these?
My combobox is set to ItemsSource="{Binding Meters}"
<ControlTemplate TargetType="ComboBoxItem">
<Grid HorizontalAlignment="Stretch" TextElement.FontWeight="Normal">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="85" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" SharedSizeGroup="Status" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" SharedSizeGroup="ExpectMfactor" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Path=MtrNo}" />
<Rectangle Grid.Column="1" Width="1" Fill="Black" />
<TextBlock Grid.Column="2" Text="{Binding Path=Status}" Margin="5,0,5,0" />
<Rectangle Grid.C开发者_高级运维olumn="3" Width="1" Fill="Black" />
<TextBlock Grid.Column="4" Text="{Binding Path=ExpectMfactor}" Margin="5,0,5,0" />
</Grid>
</ControlTemplate>
You can't do this with item template
it's better to use a DataGrid
or ListView
Inside ComboBox
精彩评论