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 屬性。

這個方法的預設實作會搜尋名稱為 Namespace.ControlName.Icon.Extension 的影像。

目前,僅可辨認下列副檔名:

  • .png

  • .bmp

  • .gif

  • .jpg

  • .jpeg

.NET Framework 安全性

請參閱

參考

NewItemFactory 類別

Microsoft.Windows.Design.PropertyEditing 命名空間

其他資源

WPF 設計工具擴充性