Getting a reference to an element's parent Window

You can call the GetElementWindow() method of the MM .NET Window Manager to get a reference to the parent form.

For example, in C#:

public class MyTextBox : TextBox
{
	public MyTextBox()
	{
		Window ParentWindow = mmAppWPF.WindowManager.GetParentForm(this);
		// Perform processing
	}
}

And in VB .NET:

Public Class MyTextBox
   Inherits TextBox
   
   Public Sub New()
      Dim ParentWindow As Window = mmAppWPF.WindowManager.GetParentWindow(Me)
      ' Perform processing
   End Sub 

End Class

If you want to return the Window as type mmBusinessWindow (it just performs the type conversion for you) you can call the Window Manager's GetElementBusinessWindow() method instead. However, you should always check for null to make sure the conversion worked.

For example, in C#:

public class MyTextBox : TextBox
{
	public MyTextBox()
	{
		mmBusinessWindow ParentWindow = mmAppWPF.WindowManager.GetParentForm(this);
		if (ParentWindow != null)
		{
			// Perform processing
		}
	}
}

And in VB .NET:

Public Class MyTextBox
   Inherits TextBox
   
   Public Sub New()
      Dim ParentWindow As mmBusinessWindow = mmAppWPF.WindowManager.GetParentWindow(Me)
	If ParentWindow IsNot Nothing Then
	      ' Perform processing
	End If
   End Sub 

End Class


© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 04/26/12
Comment or report problem with topic