0

Is it possible to update the UI of Project1 using Project2 in the same solution? I managed to run and access the classes in Project1 using Project2 but not the controls. So far I tried the ff:

In Project1 Loaded() event:

    Dim newMenu As MenuItem
    newMenu = New MenuItem()
    newMenu.Header = "This is new"
    newMenu.Tag = "1"
    AddHandler newMenu.Click, New EventHandler(AddressOf menuClick)
    myMenu.Items.Add(newMenu)

In menuClick(),

Private Sub menuClick(sender As Object, e As RoutedEventArgs)
    If sender.Tag = "1" Then
        Dim progTag As Integer = Integer.Parse(sender.Tag)
        Dim restriction = (From x In localdb.Restrictions
                           Where x.Username = "oliverc" Where x.Program_ID = progTag
                           Select x.Module_ID)

        If restriction.Count > 0 Then
            For Each ListItem In restriction.ToList
                restrict.Add(New Project2.Restrictions() With {.RestrictionTag = ListItem.ToString})
            Next
        End If

        For Each ListItem In restrict
            MessageBox.Show(ListItem.RestrictionTag(0))
        Next



        Dim frm As Project2.MainWindow = New Project2.MainWindow()
        frm.ShowDialog()

    End If
End Sub

In Project2 Loaded(),

 For Each ListItem In listOfRestriction
        Select Case ListItem.ToString
            Case "1"
                btn_addRegion.IsEnabled = False
        End Select
        MessageBox.Show(ListItem.ToString)
    Next
newbie boy
  • 5
  • 1
  • 5

1 Answers1

0

Short answer: No.

Long answer:

Each project will be compiled to a standalone .exe or .dll. Even if the current way you're trying to do it would be possible, the Project2-exe cannot possibly know which instance (if there is any at the time) of Project1 it should modify.

In order to communicate at all with the other exe you need to implement Interprocess communication. Then you'd have to have Project1 change itself whenever it is told to do so by Project2.

Some types of IPC you can use:

Community
  • 1
  • 1
Visual Vincent
  • 18,045
  • 5
  • 28
  • 75