How to bind to the Enabled property of a ToolStripMenuItem

.net, binding, vb.net, winforms

Solution

I found the answer here: create a custom ToolStripMenuItem that implements IBindableComponent.

Example from the link:

Public Class BindableToolStripMenuItem
    Inherits ToolStripMenuItem
    Implements IBindableComponent

    Private m_bindingContext As BindingContext
    Private m_dataBindings As ControlBindingsCollection

    <Browsable(False)> _
    Public Property BindingContext() As BindingContext
        Get
            If m_bindingContext Is Nothing Then
                m_bindingContext = New BindingContext()
            End If
            Return m_bindingContext
        End Get
        Set(value As BindingContext)
            m_bindingContext = value
        End Set
    End Property

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _
    Public ReadOnly Property DataBindings() As ControlBindingsCollection
        Get
            If m_dataBindings Is Nothing Then
                m_dataBindings = New ControlBindingsCollection(Me)
            End If
            Return m_dataBindings
        End Get
    End Property
End Class

Problem

I'm trying to do MVP where I have a view specific model that the presenter manipulates and the view binds to. There is no other connection between the presenter and view (the view fires off commands to the domain model via a gateway type pattern). As you can guess, this makes the ability to bind to any property of any object really important. I'm having trouble finding the correct way to bind to the `Enabled` property of a `ToolStripMenuItem`. Most controls have a `.DataBindings` property, but this one seems to lack it. I haven't found much info online about how to do this. Is it even possible?

Original source