WPF and Silverlight Learning notes (11): WPF control content Model

Source: Internet
Author: User
Tags header xmlns silverlight

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.