Frage

This is probably a dumb question (I really am new to WPF), but is there an easy way to automatically discover the available templates parts (PART_*) when overriding a control appearance in Visual Studio's Xaml editor?

I know I can use tools like Reflector or look at the documentation. What I'm looking for here is efficiency. Certainly, there has to be a contextual, intellisense-like helper somewhere, that makes available TemplatePart details appears as I type or click on a button in the editor's contextual menu? I can't possibly be the only one who'd find that useful?!

War es hilfreich?

Lösung

You can hit F12 in Visual Studio (in code, not the XAML editor) to go to the type definition -- you should see the list of template parts at the top of the class. AFAIK this is the best you can do in Visual Studio (Blend might have something better, I'm not sure).

For example, here is the DataGrid definition with its TemplateParts:

// Summary:
//     Displays data in a customizable grid.
[StyleTypedProperty(Property = "CellStyle", StyleTargetType = typeof(DataGridCell))]
[StyleTypedProperty(Property = "ColumnHeaderStyle", StyleTargetType = typeof(DataGridColumnHeader))]
[StyleTypedProperty(Property = "DragIndicatorStyle", StyleTargetType = typeof(ContentControl))]
[StyleTypedProperty(Property = "DropLocationIndicatorStyle", StyleTargetType = typeof(ContentControl))]
[StyleTypedProperty(Property = "RowHeaderStyle", StyleTargetType = typeof(DataGridRowHeader))]
[StyleTypedProperty(Property = "RowStyle", StyleTargetType = typeof(DataGridRow))]
[TemplatePart(Name = "ColumnHeadersPresenter", Type = typeof(DataGridColumnHeadersPresenter))]
[TemplatePart(Name = "FrozenColumnScrollBarSpacer", Type = typeof(FrameworkElement))]
[TemplatePart(Name = "HorizontalScrollbar", Type = typeof(ScrollBar))]
[TemplatePart(Name = "RowsPresenter", Type = typeof(DataGridRowsPresenter))]
[TemplatePart(Name = "ValidationSummary", Type = typeof(ValidationSummary))]
[TemplatePart(Name = "VerticalScrollbar", Type = typeof(ScrollBar))]
[TemplateVisualState(Name = "Disabled", GroupName = "CommonStates")]
[TemplateVisualState(Name = "Invalid", GroupName = "ValidationStates")]
[TemplateVisualState(Name = "Normal", GroupName = "CommonStates")]
[TemplateVisualState(Name = "Valid", GroupName = "ValidationStates")]
public class DataGrid : Control
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top