问题描述
我已经研究了好几天,找不到解决方案,请帮忙。
我有一个 WPF 应用程序我有一个 DataGridComboBox 它里面有东西(参数列表)。我还可以将手写输入的文本添加到组合框中,例如“测试”,如下图所示。
当我添加“测试”并单击离开或添加新行时,我应该在组合框下拉列表中看到“测试”。相反,我看到“xFRACASDataController.xFRACASFieldMapper+FieldMappingRow”,其中到底是“测试”
这里是 vb。
Private Sub xDcMappingDataGrid_CellEditEnding(sender As Object,e As DataGridCellEditEndingEventArgs) Handles xDcMappingDataGrid.CellEditEnding
'get the list from the data grid on mapping tab
Dim listofRows As New ObservableCollection(Of FieldMappingRow)
listofRows = dataMapviewmodel.DgRecords
'For Each r In xDcMappingDataGrid.Items
' 'stringList.Add(r)
' listofRows.Add(r)
'Next
dataMapviewmodel.AddtoArgumentDropDownList(sender.Items.CurrentItem.ToString)
'dataMapviewmodel.AddtoArgumentDropDownList(sender.ArgumentDropDownList(1))
'dataMapviewmodel.AddtoArgumentDropDownList(sender.Items.ToString)
'dataMapviewmodel.AddtoArgumentDropDownList(sender.dataGridRow.Item.ToString)
'dataMapviewmodel.AddtoArgumentDropDownList("TESTING1")
'dataMapviewmodel.AddtoArgumentDropDownList("TESTING2")
'dataMapviewmodel.AddtoArgumentDropDownList("TESTING3")
End Sub
这里是 F# 代码
member x.AddtoArgumentDropDownList(argumentText:string) =
argumentDropDownList.Add(argumentText)
//Add new Argument in Text to argumentDropDownList
//Check to see if Text is already in the argumentDropDownList
//If its there throw it way
//if Not add it to the argumentDropDownList
member x.ArgumentDropDownList
with get() = argumentDropDownList
and set(t: List<string>) =
argumentDropDownList.Clear()
for aField in t do
argumentDropDownList.Add(aField)
x.TriggerPropertyChanged("ArgumentDropDownList")
member x.Arg1
//with get() = argumentDropDownList
with set(t: string) =
//argumentDropDownList.Clear()
//for aField in t do
argumentDropDownList.Add(t)
x.TriggerPropertyChanged("ArgumentDropDownList")
如果我将 Jam "TESTING1" 放在组合框下拉菜单中。我已将手表添加到 Items.CurrentItem。如下所示。 “测试”在 Arg1 中
但不在物理列表中。 任何帮助都非常有帮助。
解决方法
请注意,您的问题不太可能得到很好的答案,因为它非常具体,我们无法运行您的代码。
然而,xFRACASDataController.xFRACASFieldMapper+FieldMappingRow
是一种字符串,当你在一个没有实现任何巧妙的文本格式的对象上运行 ToString
时会得到它——它似乎是一个类的名称,在本例中为 FieldMappingRow
(它是 xFRACASFieldMapper
中的嵌套类)。
在您发布的代码中,您在线上调用了 VB 代码中的 ToString
:
dataMapViewModel.AddtoArgumentDropDownList(sender.Items.CurrentItem.ToString)
sender.Items.CurrentItem
的类型是什么?这可能是 FieldMappingRow
的一个实例吗?如果是这样,那么我认为您需要通过调用 ToString
以外的其他方式从对象中提取文本。