Adding a Combobox to a DataGrid in Silverlight
Posted
by bplus
on Stack Overflow
See other posts from Stack Overflow
or by bplus
Published on 2010-05-26T08:30:16Z
Indexed on
2010/05/26
8:41 UTC
Read the original article
Hit count: 474
I can add a Combobox to a DataGrid using following xmal:
<local:DataGridTemplateColumn Header="SomeHeader" Width="106" HeaderStyle="{StaticResource headerAlignRightStyle}" CellStyle="{StaticResource cellAlignRightStyle}">
<local:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding SomeProp}" Margin="4"/>
</DataTemplate>
</local:DataGridTemplateColumn.CellTemplate>
<local:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox
x:Name="SomeCombo"
SelectionChanged="SomeCombo_SelectionChanged"
ItemsSource="{Binding SomeList}"
DisplayMemberPath="Name"
/>
</DataTemplate>
</local:DataGridTemplateColumn.CellEditingTemplate>
</local:DataGridTemplateColumn>
However what I can't figure out is a sensible way to get the row that was combox is bound to. i.e. when handling the combobox SelectionChanged event I have no way of knowing what what row the combobox belongs to. Particularly I don't know what object in the DataGrid datasource that the combobox is refering to.
Any help would be much appreciated.
© Stack Overflow or respective owner