Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

C#


var query = from e in _container.EmailAddresses select e
this.EmailAddresses = new DataServiceCollection<emailaddresses>(query).



When I make an usercontrol like this

XML
<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
C#
var query = from r in _container.Recruiters.Expand(r => r.EmailAddresses) select r

this.Recruiters = new DataServiceCollection<Recruiters>(query).


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
Posted
Updated 24-Nov-14 4:05am
v3

Figured it out.

Change the xaml to
XML
<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>
 
Share this answer
 
v2
XML
<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>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900