Working with MM .NET Maintenance Windows
The MM .NET WPF Maintenance Window template contains a tab control with a List and a Properties tab. The List tab contains a DataGrid control along with New, Delete, and Close buttons:

The Properties tab contains Save and Cancel buttons as well as nested grid layout panels into which you can add user interface elements. This window is designed so that when the user selects an item in the DataGrid, the controls you add to the Properties tab automatically display the selected item.
Adding Elements to the Properties Tab
In Expression Blend (the best tool for laying out your user interface), go to the Objects and Timeline palette and double click grdControls. This selects the grid for adding controls and displays its columns:

By default there are two columns in the grid (you can change this at will). Normally, the first column for labels and the second column for user interface elements such as text boxes and combo boxes. You need to add rows to this grid to hold your custom elements. To do this, select the grid in design mode, then go to the Properties window and click the RowDefinition property's ellipses button [...]. This launches a dialog that allows you to specify the required number of rows and lets you set the height of all rows according to your needs.
Registering Business Objects with the Window
To register business objects with the WPF window, simply create a window-level variable to hold a reference to the business object and then add code to the window's constructor to instantiate and register each business object. Remember to register one business object as the window's primary business object.For example, in C#"
public partial class UserWindow : mmBusinessWindow
{
/// <summary>
/// User business object
/// </summary>
protected User User;
/// <summary>
/// Constructor
/// </summary>
public UserWindow()
{
// Instantiate and register business objects
this.User = (User)this.RegisterPrimaryBizObj(new User());
And in VB .NET:
Public Partial Class UserWindow
Inherits mmBusinessWindow
''' <summary>
''' User business object
''' </summary>
''' <remarks></remarks>
Protected User As User
''' <summary>
''' Constructor
''' </summary>
Public Sub New()
'' Instantiate and register business objects
Me.User = CType(Me.RegisterPrimaryBizObj(New User()), User)
You also need to add code to your window that retrieves items that fill the DataGrid on the list page. Typically, the best place to do this is in a handler for the Window's Loaded. The MM .NET WPF Maintenance Window already has a Window_Loaded event handler method you can override and place the necessary code in it.
For example, in C#:
protected override void Window_Loaded(object sender, RoutedEventArgs e)
{
base.Window_Loaded(sender, e);
// Get the user entities
this.DataContext = this.User.GetAllEntities();
// Hide the new item row place holder in the Order Detail DataGrid
((IEditableCollectionView)CollectionViewSource.GetDefaultView(this.grdUsers.ItemsSource)).NewItemPlaceholderPosition =
NewItemPlaceholderPosition.None;
}
And in VB .NET:
Protected Overrides Sub Window_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
MyBase.Window_Loaded(sender, e)
'' Get the user entities
Me.DataContext = Me.User.GetAllEntities()
'' Hide the new item row place holder in the Order Detail DataGrid
CType(CollectionViewSource.GetDefaultView(Me.grdUsers.ItemsSource), _
IEditableCollectionView).NewItemPlaceholderPosition = NewItemPlaceholderPosition.None
End Sub
This code first calls the base class method, retrieves the entities and stores them in the DataGrid's DataContext, then it hides the DataGrid's default new row placeholder (an overly complex, but necessary step--Microsoft should add a property that lets you turn this off!)
Data Binding User Interface Elements
Creating a Window-Level Data Context
Typically on the more simple maintenance windows, you can create a window-level data context that can be used as the default data binding mechanism for most user interface elements. Here are the basic steps to create this data context in Expression Blend:- Select the Window in design mode, then in the Properties panel, click the DataContext property's New button.
- In the Select Object dialog, select the business entity you want to use for the data context, then click OK
Binding the DataGrid
To bind the DataGrid, follow these steps:- Select the DataGrid in design mode, then go to the Properties panel and next to the ItemsSource property, click the tiny, square Advanced Properties button and select Data Binding... from the shortcut menu
- In the Create Data Binding dialog, the Explicit Data Context tab should be automatically selected, as well as the business entity you specified for the window-level data context. Click OK to bind to this data context.
Binding UI Elements on the Properties Tab
Follow these steps to bind UI elements on the Properties tab:- Select the user interface element in design mode, then go to the Properties panel and locate the property of the UI element you want to data bound (for example, Text for text boxes)
- Click the tiny, square Advanced Properties button to the right of the property and select Data Binding... from the shortcut menu
- In the Create Data Binding dialog, the Explicit Data Context tab should already be selected, as well as the business entity you specified for the window-level data context. Expand the entity node and select the entity property you want to bind to and click OK to create the data binding
Binding the Buttons
The buttons on the WPF Maintenance Window are specialized MM .NET buttons that work in conjunction with your window's primary business object. To make sure these buttons enable/disable properly it's best to explicitly specify the primary business object in each button's BindingSource property (you don't need to do this on the Close button).To do this, just go to the BindingSource property in the Properties panel and specify the class name of the window's primary business object.
Setting up the DataGrid
Follow these steps to set up columns and improve the appearance of the DataGrid on the List tab:- Open the project in Expressoin Blend, and select the DataGrid on the List page in design mode. Go to the Expression Blend Properties panel and under the Common Properties section, uncheck the AutoGenerateColumns check box.
- Under the Common Properties section, set the GridLinesVisibility property to None.
- Under Common Properties, set the HeaderVisibility to Column. This prevents the row headers from appearing and gives the DataGrid a cleaner look.
- In the Properties panel under the Miscellaneous section, set the SelectionMode to Single. This specifies that clicking in any DataGrid column selects the entire row.
- In the Common Properties section, click the Columns (Collection) ellipses button [...] to launch the DataGridColumn Collection Editor.
- For each column you want to display in the DataGrid, click the Add another item button to launch the Select Object dialog. Select the type of column you want, then click OK to add the new column to the DataGrid:

After adding the columns, it's best to set the Width property of each column to some percentage of the total width (such as .25*, .75*). This ensures the columns completely fill the DataGrid without the need for a horizontal scroll bar.
For each column, you also need to specify the Binding property (to specify which Entity property to display in the column) and the Header property to define the header text for the column.
Specifying the Element to Receive Focus
Typically, when the user presses the New, Cancel, and Save buttons on a maintenance window, you want to change focus to another control to give them a visual cue that the action took place.By default, the following properties are set by default in the window's constructor to the window's New button:
- FocusOnCancel
- FocusOnLoad
- FocusOnSave
You can leave these settings, or specify a different user interface element.
Typically, when you click the New button on the List page, you want to set focus to a user interface element on the Properties page. To do this, add a line of code to the window's constructor that specifies the user interface element you want to receive focus.
For example, in C#:
his.FocusOnNewElement = this.txtFirstName;
And in VB .NET:
Me.FocusOnNewElement = Me.txtFirstName
For more information, check out the Help topic Specifying the Control to Receive Focus.
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 04/26/18
Comment or report problem with topic
