Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Collapse]eXpressApp Framework
 [Expand]Fundamentals
 [Expand]Getting Started
 [Expand]Concepts
 [Expand]Design-Time Features
 [Expand]Functional Testing
 [Expand]Deployment
 [Collapse]Task-Based Help
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]Actions
  [Expand]Navigation
  [Expand]Views
  [Expand]List Editors
  [Expand]Property Editors
  [Expand]Templates
  [Expand]Filtering
  [Expand]Reporting
  [Expand]Dashboards
  [Expand]Scheduler and Notifications
  [Expand]Maps
  [Expand]Security
  [Expand]Workflow
  [Expand]Localization
  [Expand]Testing
  [Collapse]Miscellaneous UI Customizations
    How to: Add a button to a Form using Custom View Item
    How to: Adjust the Size and Style of Pop-up Dialogs (ASP.NET)
    How to: Adjust the Windows' Size and Style
    How to: Change an Application Logo and Info
    How to: Create a Custom Control Detail Item
    How to: Customize a Window Caption
    How to: Customize ASP.NET Layout Elements Using Custom CSS Classes
    How to: Customize Export Options of the Printing System
    How to: Customize the Conditional Appearance Module Behavior
    How to: Customize Window Status Messages
    How to: Enable High DPI Support in a WinForms Application
    How to: Implement a Custom Messaging Class
    How to: Include an Action to a Detail View Layout
    How to: Set Images and Captions for Enumeration Values
    How to: Show a Custom Confirmation Window
    How to: Show a Custom Window with an Embedded XAF View
    How to: Show a Custom Windows Form
    How to: Use a Custom Splash Screen
    How to: Use Custom Themes in ASP.NET Applications
 [Expand]Frequently Asked Questions
 [Expand]API Reference
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
[Expand]End-User Documentation

How to: Show a Custom Windows Form

In XAF WinForms applications, it is possible to show custom windows using standard Windows Forms approaches, such as the Form.Show and Form.ShowDialog methods. If a Form should show data from the application's database, it is possible to use XAF mechanisms for CRUD operations using the IObjectSpace interface. This topic demonstrates how to initialize and show a custom Form when an XAF action is clicked.

Expanded Show a Custom Window

The steps below describe how to show a custom window on an Action's Execute event.

  • Create and design a custom Form, for example NonXAFForm.
  • Create a new ViewController descendant and add a new SimpleAction in its constructor.
  • In the Action's Execute event handler, create a new instance of your custom NonXAFForm.
  • Invoke the window using the Form.ShowDialog method.

Expanded Show a Custom Window with XAF Data

In this example, a custom window with the DataGridView control is invoked when an Action's Execute event occurs. Follow the steps below to implement this behavior.

  • Create and design a custom Form, for example NonXAFForm.
  • Create a new ViewController descendant and add a new SimpleAction in its constructor.
  • In the Action's Execute event handler, create a new instance of your custom NonXAFForm.
  • Create a new IObjectSpace instance using the XafApplication.CreateObjectSpace method.
  • Get a collection of Contact type objects using the IObjectSpace.CreateCollection method and set it as a data source for the DataGridView control.
  • Set the DataGridView control as a layout item and invoke the window using the Form.ShowDialog method.

If you have an already designed form and wish to display XAF data within one of the controls placed on the form, you can create a new constructor of this form with a parameter of the IObjectSpace type. In this constructor, specify the control's DataSource property using the IObjectSpace.GetObjects method. An example of this constructor is given in the code snippet below.

Expanded See Also

How would you rate this topic?​​​​​​​