获取指定 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
要为其获取图像的类型。
- desiredSize
类型:System.Windows.Size
请求的图像大小。
- imageName
类型:System.String%
找到的图像的名称。
返回值
类型:System.IO.Stream
一个 Stream,表示要为 type 显示的图像。
异常
异常 | 条件 |
---|---|
ArgumentNullException | type 为 nullnull 引用(在 Visual Basic 中为 Nothing)。 |
备注
此方法在控件所在的程序集内搜索嵌入资源。
如果对于 type 有多种图像可用,则此方法将检索与 desiredSize 最接近的图像。 不能保证此方法返回与 desiredSize 完全匹配的图像。
此方法返回的对象可以设置为 ContentControl 的 Content 属性。
此方法的默认实现将搜索名为命名空间.控件名称.图标.扩展名 的图像。
目前,只能识别下列扩展名:
.png
.bmp
.gif
.jpg
.jpeg
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。
请参见
参考
Microsoft.Windows.Design.PropertyEditing 命名空间