Hi,
I am trying to bind a collection to datagrid combobox and this collection is different for each row in the data grid.
pls have a look at the below code , I could not able to bind the Artist collection for each row in the combobox.
Can someone help on this please.
Note: Songs is observable collection of Song Class.
public
class Song
{
#region
Properties
public string ArtistName { get; set; }
public string SongTitle { get; set; }
public List<Artist> Artist { get; set; }
#endregion
}
public class Artist
{
public string ArtistCountry { get; set; }
}
XMAL:<DataGrid><DataGridTextColumn Header="Artist Name" Binding="{Binding ArtistName}" /><DataGridTextColumn Header="Song Title" Binding="{Binding SongTitle}" /><DataGridTemplateColumn Header="Artist Country"><DataGridTemplateColumn.CellTemplate><DataTemplate><ComboBox
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.Songs}"
SelectedValuePath="Artist.ArtistCountry"
DisplayMemberPath="Artist.ArtistCountry"
SelectedItem="{Binding Path=Artist}"
/></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn></DataGrid.Columns></DataGrid>