Using BitmapSource

Sep 20, 2010 at 10:35 PM
Edited Sep 20, 2010 at 10:39 PM

I am writing a user control. It has a property of BitmapSource which is currently set to a bmp file. In the "Loaded" event handler, I am trying to create a WiteableBitmapImage for the file. Here's my code:




    Private bmi As WriteableBitmap Private m_ImageSource As BitmapSource    
    Private m_ImageSource As BitmapSource
    Public Property ImageSource As BitmapSource
            Return m_ImageSource
        End Get
        Set(ByVal value As BitmapSource)
            m_ImageSource = value
        End Set
    End Property

    Public Sub New()
    End Sub

    Private Sub MyControl_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        If m_ImageSource Is Nothing Then Return
        bmi = New WriteableBitmap(m_ImageSource)
    End Sub


I get an error: "NullReferenceException was unhandled by user code".