2017-03-02 5 views
1

Ich bin nicht sicher, die hierarchische Vorlage von WPF steuert. Zum Beispiel für eine Combobox.Hierarchische Vorlagen von Steuerelementen

Es könnte Steuerelement Vorlage etwas wie, aber ich weiß es nicht.

Combox hat eine Vorlage Sohn ItemTemplate und ein Enkel DateTemplate. Also für eine Kontrolle, wie viele Template Söhne und Enkel? Können wir sie alle und Beziehungen in einem Diagramm aufzählen?

Antwort

0

ich erklären Unterschied zwischen den Namen der Eigenschaften und ihre Typen im Folgenden:

<ComboBox> 
    <ComboBox.ItemTemplate> 
      <!-- Add a DataTemplate here. It determines how the content 
       of your data item appears. Use it to bind data 
       fields or format string and etc --> 
    </ComboBox.ItemTemplate> 
    <ComboBox.ItemContainerStyle> 
      <!-- Add a Style here. It determines the appearance of the 
       element (e.g., ComboBoxItem) that contains the data. Set 
       Selection behaviour, Background color, etc--> 
    </ComboBox.ItemContainerStyle> 
    <ComboBox.Template> 
      <!-- Add a ControlTemplate here. It contains the tree of 
       elements that define the desired look. Of course, most of 
       the time, you do not set this property and use the default 
       value. Use it for example to change the shape of the ToggleButton.--> 
    </ComboBox.Template> 
    <ComboBox.ItemsPanel> 
      <!-- Add an ItemsPanelTemplate here. Use it to determine the 
       the panel that the ItemsPresenter creates for the Items. 
       You can change the orientation of the ComboBoxItems here .--> 
    </ComboBox.ItemsPanel> 
</ComboBox> 

hoffe, es hilft.

+0

Also das für Combobox. In der allgemeinen Kontrolle, sagen wir, wenn es eine Schaltfläche ist, hat es das gleiche Muster? – Bigeyes

+0

Nein, ein Button hat nicht 'ItemTemplate',' ItemContainerStyle'' und 'ItemsPanel''. Diese sind spezifisch für ['' ItemsControl''] (https://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol (v = vs.110) .aspx) und andere Steuerelemente abgeleitet von B. '' ListBox'', '' TreeView'' usw. '' Button'' hat eine '' Template'' Eigenschaft vom Typ '' ControlTemplate''. Tatsächlich benötigt es diese Eigenschaften nicht. – Ron

+0

So hat jedes Steuerelement sein eigenes Muster. Wie kann ich diese speichern? – Bigeyes