Displaying a second form in WPF

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

Currently I have declared the subform as globaly

Public GlobalWindowBookmark As WindowEditBookmark

      

Then I create a form and pass an object to it.

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

      

It just doesn't feel right and also allows multiple windows. Any help would be appreciated.

Thank,

0


source to share


1 answer


Do you want the auxiliary form to be a modal dialog, that is, to prevent the user from interacting with the main form while it is there? If so, you can do something like this (sorry if my VB is not entirely correct, I usually use C #):

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

      



There is also a Show method that displays the window but does not make it modal. This can help if you don't want the subform to be modal.

+3


source







All Articles