更新:2007 年 11 月
用以建立自訂分類編輯器的抽象類別。
命名空間: Microsoft.Windows.Design.PropertyEditing
組件: Microsoft.Windows.Design (在 Microsoft.Windows.Design.dll 中)
語法
Public MustInherit Class CategoryEditor
Dim instance As CategoryEditor
public abstract class CategoryEditor
public ref class CategoryEditor abstract
public abstract class CategoryEditor
備註
衍生自這個類別,以針對屬性瀏覽器主應用程式中的一組屬性提供自訂 CategoryEditor。這個類別代表自訂使用者介面,可供編輯一組相關的屬性,例如 [Text] 分類中的屬性。
TargetCategory 屬性會指出這個編輯器要用來編輯的相關屬性分類。例如,在 [屬性] 視窗中,有數個與文字相關的屬性便出現在 [Text] 分類之下。如果編輯器是設計來編輯這些屬性,TargetCategory 屬性就會傳回 "Text"。
EditorTemplate 屬性會傳回此編輯器之視覺化介面的 XAML 樣板。這通常是在專案其他地方的 ResourceDictionary 中提供的。
請注意,在設計工具使用 CategoryEditor 之前,必須先註冊編輯器。如需詳細資訊,請參閱 IRegisterMetadata。
範例
下列程式碼範例會示範如何使用 CategoryEditor 類別。如需詳細資訊,請參閱逐步解說:建立分類編輯器。
Public Class TextCategoryEditor
Inherits CategoryEditor
' The EditorResources class in this example inherits ResourceDirectory and
' contains the template for the category editor. This would be defined in
' an associated XAML file named EditorResources.xaml
Private res As New EditorResources()
Public Overrides Function ConsumesProperty(ByVal prop As PropertyEntry) As Boolean
Return True
End Function
Public Overrides ReadOnly Property EditorTemplate() As System.Windows.DataTemplate
Get
Return CType(res("TextCategoryEditorTemplate"), DataTemplate)
End Get
End Property
Public Overrides Function GetImage(ByVal desiredSize As System.Windows.Size) As Object
Return Nothing
End Function
Public Overrides ReadOnly Property TargetCategory() As String
Get
Return "Text"
End Get
End Property
End Class
public class TextCategoryEditor : CategoryEditor
{
// The EditorResources class in this example inherits ResourceDictionary
// and contains template for the category editor. This would be
// defined in an associated XAML file named EditorResources.xaml
private EditorResources res = new EditorResources();
public TextCategoryEditor()
{
}
public override bool ConsumesProperty(PropertyEntry property)
{
return true;
}
public override DataTemplate EditorTemplate
{
get
{
return res["TextCategoryEditorTemplate"] as DataTemplate;
}
}
public override object GetImage(Size desiredSize)
{
return null;
}
public override string TargetCategory
{
get { return "Text"; }
}
}
繼承階層架構
System.Object
Microsoft.Windows.Design.PropertyEditing.CategoryEditor
執行緒安全
這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。
請參閱
參考
Microsoft.Windows.Design.PropertyEditing 命名空間