tags:

views:

261

answers:

1

I have a main form and as sub form. I need the main Form to display the sub Form and pass into the constructor an object. When the sub Form is done it needs to destroy itself so the cycle can be repeated.

Currently I declared the sub form globaly

Public GlobalWindowBookmark As WindowEditBookmark

I then create the form and pass it the object.

GlobalWindowBookmark = New WindowEditBookmark(CType(_MenuBookmark, BookmarkItem))
GlobalWindowBookmark.Visibility = Windows.Visibility.Visible

This just does not feel right and also allows for multiple windows. Any help would be appreciated.

Thanks,

+3  A: 

Do you want the sub form to be a modal dialog - i.e. not allow the user to interact with the main form while it's up? If so, you could do something like this (sorry if my VB is not completely correct, I use C# normally):

Dim wndBookmark as New WindowEditBookmark(CType(_MenuBookmark, BookmarkItem))
wndBookmark.ShowDialog()

There is also a Show method, which displays the window but doesn't make it modal. That might help if you don't want the subform to be modal.

Andy