Silverlight DomainCollectionView в VB.NET - PullRequest
0 голосов
/ 28 марта 2012

Кто-нибудь может поделиться кодом для DomainCollectionView в VB.NET? У меня есть ошибка, Аргумент не указан для параметра 'op' из 'Private Sub OnLoadProductPMListCompleted (op As System.ServiceModel.DomainServices.Client.LoadOperation (Of ProductPM))'.

Public Sub New()
    InitializeComponent()
    Dim collectionViewLoader As DomainCollectionViewLoader(Of ProductPM)
    collectionViewLoader = New DomainCollectionViewLoader(Of ProductPM)(Function() Me.LoadProductPMList(), Me.OnLoadProductPMListCompleted)
    ProductCollectionView = New DomainCollectionView(collectionViewLoader, Products)
    ProductCollectionView.Refresh()
    Me.ProductListBox.ItemsSource = ProductCollectionView
End Sub

Public Function LoadProductPMList() As LoadOperation(Of ProductPM)
    Dim qry As EntityQuery(Of ProductPM) = context.GetProductsQuery

    Return context.Load(qry)
End Function

Private Sub OnLoadProductPMListCompleted(op As LoadOperation(Of ProductPM))

    If op.HasError = True Then


    ElseIf op.IsCanceled = False Then
        CType(Products, EntityList(Of ProductPM)).Source = op.Entities
    End If
End Sub

1 Ответ

1 голос
/ 29 марта 2012

Извините за поздний ответ, я был занят. Я исправил код, как указано ниже:

Dim context As ProductPMContext
Dim productCollectionView As DomainCollectionView
Dim products As IEnumerable(Of ProductPM)

Public Sub New()
    InitializeComponent()

    context = New ProductPMContext()

    'You need to initialise the products collection
    products = New EntityList(Of ProductPM)(context.ProductPMs)

    Dim collectionViewLoader As DomainCollectionViewLoader(Of ProductPM)

    'Have fixed this line, using AddressOf
    collectionViewLoader = New DomainCollectionViewLoader(Of ProductPM)(AddressOf LoadProductPMList, AddressOf OnLoadProductPMListCompleted)

    productCollectionView = New DomainCollectionView(collectionViewLoader, products)
    productCollectionView.Refresh()

    ProductListBox.ItemsSource = productCollectionView
End Sub

Public Function LoadProductPMList() As LoadOperation(Of ProductPM)
    Return context.Load(context.GetProductsQuery)
End Function

Private Sub OnLoadProductPMListCompleted(ByVal op As LoadOperation(Of ProductPM))
    If op.HasError = True Then


    ElseIf op.IsCanceled = False Then
        CType(products, EntityList(Of ProductPM)).Source = op.Entities
    End If
End Sub

Надеюсь, это поможет ...

Chris

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...