Datagrid Displaymemberpath [英] Datagrid Displaymemberpath
问题描述
我有一个带有comboboxcolumn的datagrid,它工作正常,但是有可能获得2个Displaymembers吗?我想在框中显示前名和姓氏,但我只得到其中之一...
i have a datagrid with a comboboxcolumn which works fine, but is it possible to get 2 Displaymembers? I want to show fore- and lastname in the box, but i just get one of them...
<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>
我只想使用一列的原因是,我只想要一个标题(在我的情况下:员工)你们看到我的问题了吗?也许有一个datatemplate的可能性:)
the reason why i want to use just one column is, that i just want one header (in my case: employees) u guys see my problem? Maybe there is a possibility with a datatemplate :)
推荐答案
DisplayMemberPath
属性允许您在仅显示绑定属性的情况下不创建自定义 DataTemplate
班级.如果您需要的不仅仅是显示一个属性,则应创建自己的 DataTemplate
.
DisplayMemberPath
property allows you not to create custom DataTemplate
in case of displaying only one property of a bound class. If you want something more than displaying one property you should create your own DataTemplate
.
这篇关于Datagrid Displaymemberpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!