The C1Window control includes caption bar buttons that will minimize or maximize the control. However you can also customize the appearance of the control using the WindowState property. In this topic you'll add a C1Window control to the form and three buttons: one that will minimize the window, one that will maximize the window, and one that will restore a minimized or maximized window.
Complete the following steps:
1. Create a new WPF project in Microsoft Expression Blend.
2. Click the Assets button in the Toolbar (the double-chevron icon).
3. In the dialog box locate and select the C1Window icon.
Note that if you cannot locate the C1Window icon in the dialog box, you may need to add a reference to the C1.WPF assembly first.
4. Select the page and double-click the C1Window icon in the Toolbar. The dialog window will be added to the page.
5. Select the C1Window control, navigate to the Properties window, and set the following properties:
• Set the control's Name property to "window".
• Set the control's Height to 150 and Width to 200.
• Set the control's Margin property to 5.
• Set the control's Content property to " Minimize or Maximize me!".
6. In the Toolbox, click the Panels icon (by default a Grid) and select the StackPanel item.
7. Double-click the StackPanel to add one to the application.
8. Select the StackPanel and in the Properties window set its HorizontalAlignment and VerticalAlignment properties to Center.
9. Set the StackPanel's Height and Width properties to Auto.
10. Double-click the Button icon in the Toolbox three times to add three Button controls to the StackPanel below the C1Window control.
11. Select each of the buttons in turn and set the following properties in the Properties window:
• Set the first button's Name and Content properties to "Minimize".
• Set the second button's Name and Content properties to "Maximize".
• Set the third button's Name and Content properties to "Restore".
12. Set the Margin property for each of the buttons to 5.
13. Select the Minimize button, click the lightning bolt Events icon in the Properties window.
14. Double-click the space next to the Click event to create an event handler and switch to Code view. Return to Design view and repeat this step with the remaining buttons to create a Button_Click event handler for each one.
15. In Code view, add the following import statement to the top of the page:
Imports C1.WPF
•C#
using C1.WPF;
16. Add code to the Button_Click event handlers you created earlier. They will appear similar to the following:
Private Sub Minimize_Click(ByVal sender as Object, ByVal e as System.Windows.RoutedEventArgs)
window1.WindowState = C1WindowState.Minimized
End Sub
Private Sub Maximize_Click(ByVal sender as Object, ByVal e as System.Windows.RoutedEventArgs)
window1.WindowState = C1WindowState.Maximized
End Sub
Private Sub Restore_Click(ByVal sender as Object, ByVal e as System.Windows.RoutedEventArgs)
window1.WindowState = C1WindowState.Floating
End Sub
•C#
private void Minimize_Click(object sender, System.Windows.RoutedEventArgs e)
{
this.window.WindowState = C1WindowState.Minimized;
}
private void Maximize_Click(object sender, System.Windows.RoutedEventArgs e)
{
this.window.WindowState = C1WindowState.Maximized;
}
private void Restore_Click(object sender, System.Windows.RoutedEventArgs e)
{
this.window.WindowState = C1WindowState.Floating;
}
Run the application and observe:
A dialog box appears with three buttons on the page. You can click the Minimize button to minimize the C1Window control:
You can maximize the C1Window dialog window control by clicking the Maximize button, and you can return the C1Window control to its original appearance by clicking the Restore button.