NewItemFactory.GetImageStream 方法

获取指定 Type 的图像,该图像可在集合编辑器或子属性编辑器中用作图标。

命名空间:  Microsoft.Windows.Design.PropertyEditing
程序集:  Microsoft.Windows.Design.Interaction(在 Microsoft.Windows.Design.Interaction.dll 中)

语法

声明
Public Overridable Function GetImageStream ( _
    type As Type, _
    desiredSize As Size, _
    <OutAttribute> ByRef imageName As String _
) As Stream
public virtual Stream GetImageStream(
    Type type,
    Size desiredSize,
    out string imageName
)
public:
virtual Stream^ GetImageStream(
    Type^ type, 
    Size desiredSize, 
    [OutAttribute] String^% imageName
)
abstract GetImageStream : 
        type:Type * 
        desiredSize:Size * 
        imageName:string byref -> Stream 
override GetImageStream : 
        type:Type * 
        desiredSize:Size * 
        imageName:string byref -> Stream 
public function GetImageStream(
    type : Type, 
    desiredSize : Size, 
    imageName : String
) : Stream

参数

  • type
    类型:System.Type
    要为其获取图像的类型。

返回值

类型:System.IO.Stream
一个 Stream,表示要为 type 显示的图像。

异常

异常 条件
ArgumentNullException

type 为 nullnull 引用(在 Visual Basic 中为 Nothing)。

备注

此方法在控件所在的程序集内搜索嵌入资源。

如果对于 type 有多种图像可用,则此方法将检索与 desiredSize 最接近的图像。 不能保证此方法返回与 desiredSize 完全匹配的图像。

此方法返回的对象可以设置为 ContentControlContent 属性。

此方法的默认实现将搜索名为命名空间.控件名称.图标.扩展名 的图像。

目前,只能识别下列扩展名:

  • .png

  • .bmp

  • .gif

  • .jpg

  • .jpeg

.NET Framework 安全性

请参见

参考

NewItemFactory 类

Microsoft.Windows.Design.PropertyEditing 命名空间

其他资源

WPF 设计器扩展性