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:

其他(我在非MSDN网站上发现)有误导性

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

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

09-18 02:50