This class is designed to allow parts to fill imports without the need to go through container initialization. Calls to the methods of this class are filled by using a default container loaded with all the parts found in the XAP file.

There are a few limitations on CompositionInitializer:

Parts passed to SatisfyImports for composition cannot have exports of their own, or the method will result in an exception.

Parts created by the default container to fill imports will be retained by the Managed Extensibility Framework (MEF) until the application shuts down. Long-running applications should using ExportFactory<T> to manage the life cycles of their parts.

You can replace the default container with a custom container by calling the Initialize static method.

The following code shows how to satisfy the imports for a part and get data from the part. To use this code, create a Silverlight project with a TextBox named textBox1. Add the following code to the code-behind file.