NestedContainer 类 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供 INestedContainer 接口的基实现,该接口使容器可以拥有一个所属组件。
public ref class NestedContainer : System::ComponentModel::Container, IDisposable, System::ComponentModel::IContainer, System::ComponentModel::INestedContainerpublic ref class NestedContainer : System::ComponentModel::Container, IDisposable, System::ComponentModel::INestedContainerpublic ref class NestedContainer : System::ComponentModel::Container, System::ComponentModel::INestedContainerpublic class NestedContainer : System.ComponentModel.Container, IDisposable, System.ComponentModel.IContainer, System.ComponentModel.INestedContainerpublic class NestedContainer : System.ComponentModel.Container, IDisposable, System.ComponentModel.INestedContainerpublic class NestedContainer : System.ComponentModel.Container, System.ComponentModel.INestedContainertype NestedContainer = class
    inherit Container
    interface IContainer
    interface IDisposable
    interface INestedContainertype NestedContainer = class
    inherit Container
    interface INestedContainer
    interface IContainer
    interface IDisposablePublic Class NestedContainer
Inherits Container
Implements IContainer, IDisposable, INestedContainerPublic Class NestedContainer
Inherits Container
Implements IDisposable, INestedContainerPublic Class NestedContainer
Inherits Container
Implements INestedContainer- 继承
- 实现
注解
类 NestedContainer 是 接口的 INestedContainer 简单实现,它定义了一个组件,该组件在逻辑上包含零个或多个其他组件,并且由父组件拥有。 嵌套容器的行为在很多方面都不同于标准 Container ,包括:
- 站点特征(如 DesignMode 和 GetService )通过拥有组件的站点进行路由。 
- 站点的 Name 属性是一个限定名称,其中包含拥有组件的名称,后跟句点 (.) 和子组件的名称。 
- GetService 提供对 INestedContainer 作为服务的支持。 
- 释放拥有组件时,也会释放容器。 
此外,设计器对嵌套容器的处理方式也不同。 设计器主机只对一个容器感兴趣 - 与主机关联的容器。 因此,在嵌套容器中添加或删除组件时,不会引发组件添加和删除事件。 但是,由于服务流经嵌套容器,因此当嵌套容器中的组件发生更改时,会引发组件更改事件。
事件跟踪中的这种差异也会影响撤消功能,而撤消功能与序列化密切相关。 标准撤消引擎使用 IReferenceService 跟踪对组件所做的更改。 如果撤消引擎无法通过引用服务标识组件的名称,则引擎将忽略该组件的任何更改。 仅当所包含组件的更改在其所有者中公开为同名的公共只读属性时,此服务才会自动识别对包含组件的更改。 否则,开发人员必须将组件更改事件传递给所有者。 例如,如果嵌套组件的 Text 属性作为属性 Address 重新呈现在其拥有的组件上,则更改属性 Text 时,必须以编程方式对相应的 Address 属性进行属性更改,否则不会通过撤消跟踪该更改。
构造函数
| NestedContainer(IComponent) | 初始化 NestedContainer 类的新实例。 | 
属性
| Components | 获取 Container 中的所有组件。(继承自 Container) | 
| Owner | 获取此嵌套容器的所属组件。 | 
| OwnerName | 获取所属组件的名称。 | 
方法
| Add(IComponent) | 将指定的 Component 添加到 Container。 该组件未命名。(继承自 Container) | 
| Add(IComponent, String) | 将指定的 Component 添加到 Container 并为其分配名称。(继承自 Container) | 
| CreateSite(IComponent, String) | 为容器中的组件创建站点。 | 
| Dispose() | 释放由 Container 使用的所有资源。(继承自 Container) | 
| Dispose(Boolean) | 释放由嵌套容器使用的资源。 | 
| Equals(Object) | 确定指定对象是否等于当前对象。(继承自 Object) | 
| GetHashCode() | 作为默认哈希函数。(继承自 Object) | 
| GetService(Type) | 获取指定类型的服务对象(如果可用)。 | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| Remove(IComponent) | 从 Container 中移除组件。(继承自 Container) | 
| RemoveWithoutUnsiting(IComponent) | 从 Container 中移除组件,不将 Site 设置为  | 
| ToString() | 返回表示当前对象的字符串。(继承自 Object) | 
| ValidateName(IComponent, String) | 确定组件名称对此容器是否唯一。(继承自 Container) |