我有 xaml 代码
<ListView Name="List1" Margin="0,33,0,0"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Visible"
ItemsSource="{Binding Path=Table}" MouseDoubleClick="List1_MouseDoubleClick">
<ListView.View>
<GridView x:Name="_gridView" ColumnHeaderTemplate="{StaticResource BlueHeader}">
<GridViewColumn x:Name="LoyaltyCode" Header="Code" DisplayMemberBinding="{Binding Path=LoyaltyCode}"/>
<GridViewColumn x:Name="LoyaltyName" Header="Name" Width="130" DisplayMemberBinding="{Binding Path=LoyaltyName}" HeaderTemplate="{StaticResource BlueHeaderName}"/>
<GridViewColumn Header="PurProductPonits" DisplayMemberBinding="{Binding Path=PurProductPonits}"/>
<GridViewColumn Header="PurProductAmount" DisplayMemberBinding="{Binding Path=PurProductAmount}"/>
<GridViewColumn x:Name="PurServicePonits" Header="PurServicePonits" DisplayMemberBinding="{Binding Path=PurServicePonits}"/>
<GridViewColumn Header="PurServiceAmount" DisplayMemberBinding="{Binding Path=PurServiceAmount}"/>
<GridViewColumn Header="RedeemPoints" DisplayMemberBinding="{Binding Path=RedeemPoints}"/>
<GridViewColumn Header="RedeemAmount " DisplayMemberBinding="{Binding Path=RedeemAmount}" />
<GridViewColumn Header="LoyaltyID" DisplayMemberBinding="{Binding Path=LoyaltyID}" Width="0"/>
<GridView.ColumnHeaderContainerStyle>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="IsEnabled" Value="False"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="TextElement.Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
</Style>
</GridView.ColumnHeaderContainerStyle>
</GridView>
</ListView.View>
</ListView>
后面的代码是
foreach (GridViewColumn column in _gridView.Columns)
{
if (column.Width == 0)
continue;
//ComboBoxItem item = new ComboBoxItem();
// item.Content=column.Header;
// item.Tag=column.???;
// cmbSearch.Items.Add(item);
cmbSearch.Items.Add(column.Header);
}
我需要用 column.Header填充组合框的显示项,并用“DisplayMemberBinding 路径名称”填充值项例如.. item.Content=Code , item.Tag=LoyaltyCode