DataGridComboBoxColumn

DataGridComboBoxColumn

本文介绍了DataGridComboBoxColumn 单元格不显示所选项目文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何让 DataGridComboBoxColumn 在未处于编辑模式时显示所选项目文本?以及是否可以使编辑模式下的组合框最初显示所选项目的文本?

I was wondering how you get the DataGridComboBoxColumn to display the selected item text when it is not in editing mode? And also is it possible to make it so the combo box in edit mode displays the selected item text initially?

这是我的 XAML:

<DataGridComboBoxColumn Header="Formatter"
                        SelectedItemBinding="{Binding Path=Format}">
  <DataGridComboBoxColumn.ElementStyle>
    <Style TargetType="">
      <Setter Property="Text" Value="{Binding Path=FormatView.Name}" />
    </Style>
  </DataGridComboBoxColumn.ElementStyle>
  <DataGridComboBoxColumn.EditingElementStyle>
    <Style TargetType="ComboBox">
      <Setter Property="ItemsSource" Value="{Binding Path=DefinedFormatters}" />
      <Setter Property="IsDropDownOpen" Value="True" />
      <Setter Property="ItemTemplate">
        <Setter.Value>
          <DataTemplate>
            <TextBlock Text="{Binding Path=Name}"></TextBlock>
          </DataTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </DataGridComboBoxColumn.EditingElementStyle>
</DataGridComboBoxColumn>

推荐答案

这是我发现 DataGridComboBoxColumn 上唯一有用的资源:

This was the only resource on DataGridComboBoxColumn that I found helpful:

http://msdn.microsoft.com/en-us/library/system.windows.controls.datagridcomboboxcolumn.aspx

其他所有内容(我在非 MSDN 网站上发现的)都是误导

Everything else (that I found on non-MSDN sites) was misleading!

这篇关于DataGridComboBoxColumn 单元格不显示所选项目文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-21 09:06