The WPF control content model refers primarily to the various controls that derive from the System.Windows.Controls.Control class, which are divided into four parts:
ContentControl
Headeredcontendcontrol
itemscontrol</p>
HeaderedItemsControl
Its inheritance relationship please refer to my previous blog's content.
These four classes are used as base classes for most controls in WPF. Classes that use these content models can contain the same type of content and handle the content in the same way, and any type of object that can be placed in a ContentControl (or a class inherited from ContentControl) can be Placed in a control with any of the other three content models. Such as:
1: <window x:class= "Wpfcontrolcontentmodule.winoverview"
2:xmlns= "http://schemas.microsoft.com/winfx/2006/xaml/presentation& quot;
3:xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"
4:title= "Control content Model Overview" height= "Width=" >
5: <Grid>
6: <Grid.ColumnDefinitions>
7: <columndefinition/>
8: <columndefinition/>
9: </Grid.ColumnDefinitions>
: <Grid.RowDefinitions>
One: <rowdefinition/>
A: <rowdefinition/>
</Grid.RowDefinitions>
14:
<!--ContentControl sample (Button)-->
: <textblock text= "ContentControl" grid.row= "0" grid.column= "0"/>
<button margin= "5,20,5,5" grid.row= "0" grid.column= "0" >
: <Button.Content>
: <stackpanel verticalalignment= "center" horizontalalignment= "Center" >
£ <image source= "images/dvd.png" width= "height="
<textblock text= "DVD" horizontalalignment= "Center"/>
</StackPanel>
: </Button.Content>
: </Button>
25:
<!--HeaderedContentControl sample (GroupBox)-->
: <textblock text= "HeaderedContentControl" grid.row= "0" grid.column= "1"/>
: <groupbox margin= "5,20,5,5" grid.row= "0" grid.column= "1" >
: <GroupBox.Header>
£ <textblock text= "Header Text"/>
: </GroupBox.Header>
<GroupBox.Content>
<stackpanel verticalalignment= "center" horizontalalignment= "Center" >
: <image source= "Images/dvd.png" width= "height="
<textblock text= "DVD" horizontalalignment= "Center"/>
-</StackPanel>
Panax Notoginseng: </GroupBox.Content>
: </GroupBox>
39:
<!--ItemsControl sample (ListBox)-->
: <textblock text= "ItemsControl" grid.row= "1" grid.column= "0"/>
: <listbox margin= "5,20,5,5" grid.row= "1" grid.column= "0" >
: <ListBox.Items>
<textblock text= "List Item A"/>
<button content= "List Item B"/>
<stackpanel orientation= "Horizontal" verticalalignment= "Center" >
: <image source= "images/dvd.png" width= "" "height=" "/>"
<textblock text= "DVD" horizontalalignment= "center" verticalalignment= "center"/>
: </StackPanel>
: </ListBox.Items>
Wuyi: </ListBox>
52:
<!--HeaderedItemsControl sample (TreeView)-->
Si: <textblock text= "HeaderedItemsControl" grid.row= "1" grid.column= "1"/>
<treeview margin= "5,20,5,5" grid.row= "1" grid.column= "1" >
: <TreeViewItem>
<TreeViewItem.Header>
58:tree Node A
: </TreeViewItem.Header>
<TreeViewItem.Items>
<textblock text= "Node A-1"/>
<button content= "Node A-2"/>
: <stackpanel orientation= "Horizontal" verticalalignment= "Center" >
: <image source= "images/dvd.png" width= "" "height=" "/>"
<textblock text= "DVD" horizontalalignment= "center" verticalalignment= "center"/>
: </StackPanel>
: </TreeViewItem.Items>
: </TreeViewItem>
: <TreeViewItem>
: <TreeViewItem.Header>
71:tree Node B
: </TreeViewItem.Header>
: <TreeViewItem.Items>
text=: <textblock "Node B-1"/>
<button content= "Node B-2"/>
: </TreeViewItem.Items>
: </TreeViewItem>
: </TreeView>
: </Grid>
: </Window>