【问题标题】:Datagrid Displaymemberpath数据网格显示成员路径
【发布时间】:2012-05-18 21:26:44
【问题描述】:

我有一个带有组合框列的数据网格,它工作正常,但是否有可能获得 2 个显示成员?我想在框中显示前名和姓氏,但我只得到其中一个......

<WpfToolkit:DataGrid AutoGenerateColumns="false" EnableRowVirtualization="True" Height="226" ItemsSource="{Binding Source={StaticResource DataSet}, Path=PlacementsEmployees}" HorizontalAlignment="Left" Margin="739,57,0,0" Name="mitGrid" VerticalAlignment="Top" Width="Auto" DataContext="{Binding}" RowDetailsVisibilityMode="VisibleWhenSelected" IsSynchronizedWithCurrentItem="True" IsReadOnly="True" FontFamily="Verdana" FontSize="11">
    <WpfToolkit:DataGrid.Columns>
        <WpfToolkit:DataGridComboBoxColumn x:Name="test" Header="Employees" ItemsSource="{Binding Source={StaticResource DataSet}, Path=Employees}" SelectedValuePath="ID" SelectedValueBinding="{Binding Path=PE_Employees}" DisplayMemberPath="E_Surname" -> maybe "E_Forename; E_Surname" ?? <- IsReadOnly="True" />
    </WpfToolkit:DataGrid.Columns>
</WpfToolkit:DataGrid>

我只想使用一列的原因是,我只想要一个标题(在我的情况下:员工) 你们看到我的问题了吗?也许数据模板有可能:)

【问题讨论】:

  • 下拉菜单中现在显示什么?
  • 没什么,它只是用来展示的,不是用来编辑的。只读 = true :)
  • 您能否详细说明为什么要绑定到两个不同的对象 PlacementEmployees 和Employees?

标签: sql wpf datagrid combobox


【解决方案1】:

DisplayMemberPath 属性允许您在仅显示绑定类的一个属性的情况下不创建自定义DataTemplate。如果您想要的不仅仅是显示一个属性,您应该创建自己的DataTemplate

【讨论】:

  • 是的,有问题,你能帮帮我吗?
猜你喜欢
  • 2018-09-10
  • 1970-01-01
  • 2018-01-24
  • 2012-11-05
  • 2015-03-13
  • 1970-01-01
  • 2015-08-03
  • 1970-01-01
  • 2021-02-12
相关资源
最近更新 更多