How to convert ObservableListSource class from C# to VB.NET RRS feed

  • Question

  • Can someone please help me convert the following to VB.NET? Thank you.

     using System.Collections;
        using System.Collections.Generic;
        using System.Collections.ObjectModel;
        using System.ComponentModel;
        using System.Diagnostics.CodeAnalysis;
        using System.Data.Entity;
        namespace WinFormswithEFSample
            public class ObservableListSource<T> : ObservableCollection<T>, IListSource
                where T : class
                private IBindingList _bindingList;
                bool IListSource.ContainsListCollection { get { return false; } }
                IList IListSource.GetList()
                    return _bindingList ?? (_bindingList = this.ToBindingList());

    Sunday, April 9, 2017 12:06 AM


  • Try this:

    Imports System.Collections
    Imports System.Collections.Generic
    Imports System.Collections.ObjectModel
    Imports System.ComponentModel
    Imports System.Diagnostics.CodeAnalysis
    Imports System.Data.Entity
    Namespace WinFormswithEFSample
        Public Class ObservableListSource(Of T As Class)
            Inherits ObservableCollection(Of T)
            Implements IListSource
            Private _bindingList As IBindingList
            Private ReadOnly Property IListSource_ContainsListCollection() As Boolean Implements IListSource.ContainsListCollection
                    Return False
                End Get
            End Property
            Private Function IListSource_GetList() As IList Implements IListSource.GetList
                If _bindingList Is Nothing Then
                    _bindingList = Me.ToBindingList()
                End If
                Return _bindingList
            End Function
        End Class
    End Namespace

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    Sunday, April 9, 2017 10:21 AM