问题描述
我有一些招聘人员,每个招聘人员都有一组电子邮件地址。
我可以选择电子邮件地址,并将它们放入如下集合中: br $> b $ b
I have a collection of recruiters, and each recruiter has a collection of email addresses.
I can select the emailadresses and put them in a collection like:
var query =来自_container中的e。 EmailAddresses选择e
this.EmailAddresses = new DataServiceCollection< emailaddresses>(查询)。
当我进行这样的用户控制时
var query = from e in _container.EmailAddresses select e
this.EmailAddresses = new DataServiceCollection<emailaddresses>(query).
When I make an usercontrol like this
<UserControl>
<DataGrid ItemsSource="{Binding Path=Recruiters"}>
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<ItemsControl ItemsSource="{Binding DataContext.EmailAddresses, RelativeSource={RelativeSource AncestorType=UserControl}}>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Stackpanel Orientation="Vertical"/>
</ItemsPanelTemplate>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text = "{Binding Address"}/>
</DataTemplate>
</ItemtsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</UserControl>
我每行上都一样电子邮件地址,我理解。
我可以通过各自的电子邮件获得招聘人员的集合,例如
I get on each row the same email addresses, which I understand.
I can get the collection of recruiters with their respective emailaddresses like
var query = from r in _container.Recruiters.Expand(r => r.EmailAddresses) select r
this.Recruiters = new DataServiceCollection<Recruiters>(query).
我必须将usercontrol绑定到Recruiters.EamilAddresses,但这不起作用。
任何想法如何实现这一目标?
基本上我想在每一行上显示一个子集。
亲切的问候
Jeroen
I would have to bind the usercontrol to Recruiters.EamilAddresses, but that doesn't work.
Any ideas how to accomplish this?
Basically I would like to display a subcollection on each row.
Kind regards
Jeroen
推荐答案
<usercontrol>
<usercontrol.resources>
<datatemplate x:key="EamilAddresses" datatype="{x:Type something:Recruiters}" xmlns:x="#unknown">
<stackpanel orientatien="Vertical">
<textbox text="{Binding" hold=" /></StackPanel><br mode=" path="Recruiters"}">
<datagrid.columns>
<datagridtemplatecolumn>
<datagridtemplatecolumn.celltemplate>
<datatemplate>
<itemscontrol itemssource="{Binding EmailAddresses}<br mode=" hold=" />ItemTemplate="></itemscontrol></datatemplate></datagridtemplatecolumn.celltemplate></datagridtemplatecolumn></datagrid.columns></textbox></stackpanel></datatemplate></usercontrol.resources></usercontrol>
<usercontrol>
<usercontrol.resources>
<datatemplate x:key="EamilAddresses" datatype="{x:Type something:Recruiters}" xmlns:x="#unknown">
<stackpanel orientatien="Vertical">
<textbox text="{Binding" hold=" /></StackPanel><br mode=" path="Recruiters"}">
<datagrid.columns>
<datagridtemplatecolumn>
<datagridtemplatecolumn.celltemplate>
<datatemplate>
<itemscontrol itemssource="{Binding EmailAddresses}<br mode=" hold=" />ItemTemplate="></itemscontrol></datatemplate></datagridtemplatecolumn.celltemplate></datagridtemplatecolumn></datagrid.columns></textbox></stackpanel></datatemplate></usercontrol.resources></usercontrol>
这篇关于在数据网格中显示子集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!