【发布时间】:2011-02-24 01:43:49
【问题描述】:
我可以使用以下 xmal 将 Combobox 添加到 DataGrid:
<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>
但是我想不通的是获取组合框行的明智方法是 势必。即在处理组合框 SelectionChanged 事件时,我无法知道是什么 组合框属于哪一行。特别是我不知道 DataGrid 数据源中有什么对象 组合框所指的。
任何帮助将不胜感激。
【问题讨论】:
标签: silverlight datagrid combobox