tags:

views:

210

answers:

1

I have A Wpf window with a Public Sub function(Window1). I need to execute that function from another window. Something like this:

Private Sub Window2_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Window1.Loaded

Dim Window1 As New Window 1
Window1.function()

End Sub

I'm very new to wpf. Please help me on this. Thanks In Advance.

+1  A: 

Make the function public in Window1.

Class Window1 
    Public Sub MyPublicFunction()
     'DoSomething'
    End Sub
End Class

Any specific reason why it has to be in Windows1 and be an instance function? You could do this as a static public function in the App class so every part of your project gets access to it.

Carlo