我有一个DataGrid
,DataGridComboBoxColumn
我想将它绑定到一个只包含选项“A”,“B”,“C”的静态源
当前的xml:
<DataGridComboBoxColumn x:Name="ControlOption" Header ="ControlOption" Width="100"
SelectedValueBinding="{Binding Operation}"
SelectedItemBinding="{Binding Choices}"
ScrollViewer.CanContentScroll="True"
ScrollViewer.VerticalScrollBarVisibility="Auto"
IsReadOnly="True"
CanUserResize="True">
<DataGridComboBoxColumn.ElementStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding Choices}" />
</Style>
</DataGridComboBoxColumn.ElementStyle>
<DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="ComboBox">
<Setter Property="ItemsSource" Value="{Binding Choices}" />
</Style>
</DataGridComboBoxColumn.EditingElementStyle>
<DataGridComboBoxColumn.ItemsSource>
<col:ArrayList>
<sys:String>AVS</sys:String>
<sys:String>DB</sys:String>
<sys:String>AVS_DB</sys:String>
</col:ArrayList>
</DataGridComboBoxColumn.ItemsSource>
</DataGridComboBoxColumn>
请让我知道代码隐藏的样子:实现DataGridComboBox
我目前使用的代码隐藏:
_ds = new DataSet();
DataTable table = new DataTable();
_ds.Tables.Add(table);
DataColumn c1 = new DataColumn("IsActive", typeof(bool));
table.Columns.Add(c1);
DataColumn c2 = new DataColumn("DataGridTextBox_QCList1", typeof(string));
table.Columns.Add(c2);
DataColumn c3 = new DataColumn("DataGridTextBox_QCSummary", typeof(string));
table.Columns.Add(c3);
DataColumn c4 = new DataColumn("Choices", typeof(string));
table.Columns.Add(c4);
datagrid.ItemsSource = _ds.Tables[0].DefaultView;
我需要进行哪些更改才能对填充 datagridcombobox 产生必要的影响(基本问题是,我什至没有看到下拉菜单)