-
Notifications
You must be signed in to change notification settings - Fork 260
Using WinForms Commands in WPF
You can use WinForms-based command components in a WPF based application. This is made possible by the CommandServiceAdapter component, which implements the WinForms ICommandService so it works in a WPF environment. In other words, it adapts Sce.Atf.Wpf.Applications.ICommandService to Sce.Atf.Applications.ICommandService.
The CommandServiceAdapter component exports Sce.Atf.Applications.ICommandService. If this component is included in an application, the WinForms-based components that need ICommandService import it from CommandServiceAdapter, rather than the WinForms-based CommandService component. This allows the components to function with the WPF application. The application would not include the WinForms-based CommandService component in its MEF catalog in this case.
CommandServiceAdapter also creates an object of the CommandClientAdapter class, which adapts the ICommandClient interface for WinForms-based command clients to WPF. This allows command clients implementing Sce.Atf.Applications.ICommandClient to operate properly in WPF.
The StandardInteropParts class includes the CommandServiceAdapter component in a MEF TypeCatalog:
public class StandardInteropParts
{
/// <summary>
/// Gets type catalog for all components</summary>
public static ComposablePartCatalog Catalog
{
get
{
return new TypeCatalog(
typeof(MainWindowAdapter),
typeof(CommandServiceAdapter),
typeof(ContextMenuService),
typeof(DialogService),
typeof(ControlHostServiceAdapter)
);
}
}
}This catalog can be included in an AggregateCatalog, as in this line from the ATF Wpf App Sample:
return new AggregateCatalog(typeCatalog, StandardInteropParts.Catalog, StandardViewModels.Catalog);After this, the WPF application can use the WinForms-based commands component — with no additional support from the application.
- Using Commands in ATF: Overview of how commands are handled in ATF.
- CommandInfo and CommandDef Classes: Description of classes that describes command UI info.
- ATF Command Groups: Description of command groups and how commands are added to them.
- Using Standard Command Components: Outline of the components that add common commands to applications.
- Registering Menus and Commands: How to create new menus and register commands.
- Creating Command Clients: Creating command clients that implement command actions.
- Using WinForms Commands in WPF: How to use WinForms-based command components in a WPF based application.
- Using Context Menus: How to use context menus in ATF.
- Home
- Getting Started
- Features & Benefits
- Requirements & Dependencies
- Gallery
- Technology & Samples
- Adoption
- News
- Release Notes
- ATF Community
- Searching Documentation
- Using Documentation
- Videos
- Tutorials
- How To
- Programmer's Guide
- Reference
- Code Samples
- Documentation Files
© 2014-2015, Sony Computer Entertainment America LLC