2012-12-03 4 views
-1

ArcGIS를 사용하고 있습니다. 데이터를 찾은 후 수동으로 정렬하려고합니다. 불필요한 데이터를 제거하기 위해 Tlist를 통해 속성 클래스와 루프를 만들었습니다. 그러나 데이터 그리드에 바인딩되기 바로 전에 캐스팅 오류가 발생합니다. 나는 무언가가 돌아오고 있다고 생각한다. 나는 무엇인가 놓치고 있냐?? 여기 그리드에결과 정렬 (찾기 방법) 작동하지 않습니다.

Public Class temp 
    Public Sub New() 
    End Sub 
    Public Property DisplayFieldName As String 
    Public Property Feature As ESRI.ArcGIS.Client.Graphic 
    Public Property FoundFieldName As String 
    Public Property LayerId As Integer 
    Public Property LayerName As String 
    Public Property Value As Object 
End Class 

Public Class templst 
    Public Sub New() 
     Dim findresult = New List(Of temp) 
    End Sub 
    Private _findresult = findresult 
    Public Property findresult() As List(Of temp) 
     Get 
      Return _findresult 
     End Get 
     Set(ByVal value As List(Of temp)) 
      _findresult = value 
     End Set 
    End Property 
End Class 

Private Sub FindTask_Complete(ByVal sender As Object, ByVal args As FindEventArgs) 
     Dim newargs As New templst() 'puts Tlist (temp) into property 
     Dim templistNUMONLY As New List(Of temp) 'Tlist of temp 
      For Each r In args.FindResults 'class in compiled dll. 
       If Regex.Match(r.Value.ToString, "[0-9]").Success Then 
       templistNUMONLY.Add(New temp() With {.LayerId = r.LayerId, 
               .LayerName = r.LayerName, 
               .Value = r.Value, 
               .FoundFieldName = r.FoundFieldName, 
               .DisplayFieldName = r.DisplayFieldName, 
               .Feature = r.Feature}) 
       End If 
      Next 

     newargs.findresult = templistNUMONLY 

      Dim sortableView As New PagedCollectionView(newargs.findresult) 
      FindDetailsDataGrid.ItemsSource = sortableView 'populate lists here 
     End Sub 

BIND : (여기 오류)

Private Sub FindDetails_SelectionChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs) 
     ' Highlight the graphic feature associated with the selected row 
      Dim dataGrid As DataGrid = TryCast(sender, DataGrid) 

      Dim selectedIndex As Integer = dataGrid.SelectedIndex 
      If selectedIndex > -1 Then 
      '''''''''''''''''CAST ERROR HERE: 
      Dim findResult As FindResult = CType(FindDetailsDataGrid.SelectedItem, FindResult) 
+0

그래서 무엇이 문제입니까? –

+0

Im 전송 문제가있는 이유는 무엇입니까? 어떻게 해결할 수 있을까요? – user999690

답변

1

당신은 유형 temp의 객체 FindDetailsDataGrid를 채울 수 있지만, 대신 FindResult를 입력 캐스팅하려고합니다. 다음을해야합니다.

Dim selectedTemp As temp = CType(FindDetailsDataGrid.SelectedItem, temp) 
'*Create find result from selected temp object here* 
+0

그게 효과가! 정말 감사합니다. 나는 너에게 큰 시간을 보낸다! – user999690